Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: add CSV vtable module #393

Closed
kenshaw opened this issue Mar 20, 2017 · 3 comments
Closed

Feature request: add CSV vtable module #393

kenshaw opened this issue Mar 20, 2017 · 3 comments

Comments

@kenshaw
Copy link
Contributor

kenshaw commented Mar 20, 2017

The SQLite3 source provides a CSV vtable module, but it is not part of the amalgamated source. If possible, it would be great if the csv vtable module could be included in the base go-sqlite3 package, along with a related csv build tag.

This would effectively allow the following SQL:

CREATE VIRTUAL TABLE temp.t1 USING csv(filename='thefile.csv');

SELECT * FROM temp.t1;

Rationale:

It seems disjoint that there are other modules (such as json1) that are part of the amalgamated source, but that require separate build tags to enable. I understand this is likely due to a want to keep the build times as low as possible, and thus disabling extraneous features, but for completeness sake, the other base/core modules (those that have .html documentation) should at least be available via build tags.

I am happy to create a separate repository and connect up the CSV module that way, but considering how widely CSV is used, it would make sense for SQLite's core/original CSV be packaged with this repository. As such, I would be more than willing to do the work to get the csv module added to the code, and submit a proper pull request, however I would like to get a "thumbs up" before embarking on any work. If including the csv module directly is out of the question, I will just create a separate repository and connect using the appropriate hooks.

(note: I am working on some advanced features for github.com/knq/usql and would like CSV to be natively available for sqlite databases)

(btw, @mattn thanks for all your amazing Go code/repositories....!)

@ekzhu
Copy link

ekzhu commented Jun 8, 2017

Agreed. It would be very helpful to have CSV module.

@mattn
Copy link
Owner

mattn commented Jun 9, 2017

Thanks for your suggestion. I totally agree with you. As you know, CSV module is separated from codes of core. To enable CSV module, you must compile csv.so with getting code from https://www.sqlite.org/src/artifact?ci=trunk&filename=ext/misc/csv.c . And load the module like below.

	sql.Register("sqlite3_with_extensions",
		&sqlite3.SQLiteDriver{
			Extensions: []string{
				"csv",
			},
		})

However, I often feel trouble to use go-sqlite3 for unit test. For example, we want to use go-sqlite3 to load test data from CSV, as you mentioned. So I agree with you in personally.

gjrtimmer added a commit to gjrtimmer/go-sqlite3 that referenced this issue May 26, 2018
Compile Section Closes mattn#175
Compile Section Closes mattn#201
Compile Section Closes mattn#206
Compile Section Closes mattn#404
Compile Section Closes mattn#217
Compile Section Closes mattn#224
Compile Section Closes mattn#234
Compile Section Closes mattn#242
Feature table Closes mattn#255
Description Section Closes mattn#232
Golang:1.6 not supported Closes mattn#272
Golang:1.5 not supported + compilation section Closes mattn#283
usleep Implemented Closes mattn#285
FAQ Section Closes mattn#289
Compile Section closes mattn#295
FAQ Section Closes mattn#305
PR339 Closes mattn#318 mattn#321
Compilation Section Closes mattn#341
PR407 Closes mattn#364
Feature `sqlite_vtable` Closes mattn#393
Compile Section Closes mattn#416
sqlite_trace feature Closes mattn#433
Compilation Section Closes mattn#435
Compilation Section Closes mattn#443
Golang:1.6 Not Supported Closes mattn#445
Compilation Section Closes mattn#451
Compilation Section Closes mattn#467
Compilation Section Closes mattn#491
Compilation Section Closes mattn#495
Compilation Section Closes mattn#505
Compilation Section Closes mattn#557
Compilation Section Closes mattn#560
@mattn mattn closed this as completed in c9394b1 May 27, 2018
@patrickdevivo
Copy link
Contributor

Hi there, I just wanted to ask about this as it was closed by a commit (c9394b1), but I can't seem to find any implementation of it. Is it necessary to load the csv virtual table as an extension still, rather than via a build tag? It would be great if it were supported similar to other extensions enumerated in the extensions list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants