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

Blob I/O #239

Open
Tracked by #5
smhmw opened this issue Sep 16, 2015 · 9 comments
Open
Tracked by #5

Blob I/O #239

smhmw opened this issue Sep 16, 2015 · 9 comments

Comments

@smhmw
Copy link

smhmw commented Sep 16, 2015

Would it be possible to implement the blob i/o API just as the backup API ?

mxk/go-sqlite has it but is a little out of date.
gwenn/gosqlite has it too.

@mattn
Copy link
Owner

mattn commented Sep 16, 2015

database/sql doesn't provide Blob APIs. they provide Blob APIs for native driver (not database/sql).

@smhmw
Copy link
Author

smhmw commented Sep 16, 2015

Yes, but we can provide it aside from database/sql, like backup (backup.go) ? I may try to make it work locally, if it works i'll submit the patch - if that's interesting enough.

@mattn
Copy link
Owner

mattn commented Sep 16, 2015

No way to pass the Blob type into database.sql.

@gwenn
Copy link

gwenn commented Sep 18, 2015

To make it work, you need access from sql.DB to the underlying/wrapped sqlite3.SQLiteConn...

@smhmw
Copy link
Author

smhmw commented Sep 21, 2015

I don't want to access it from sql.DB, rather add an API to the lib in a similar way to sqlite3.SQLiteBackup, such as sqlite3.SQLiteBlob; and corresponding method in sqlite3.SQLiteConn such as Blob(db, table, column, rowid) (similar to SQLiteConn.Backup(...))

You would need to get the rowid from a query first, but it's also intended this way in SQLite C API : int sqlite3_blob_open( sqlite3*, const char *zDb, const char *zTable, const char *zColumn, sqlite3_int64 iRow, int flags, sqlite3_blob **ppBlob );.

I'll give it a try ...

@anacrolix
Copy link

👍

@anacrolix
Copy link

Any progress on this @smhmw ?

@gjrtimmer
Copy link
Collaborator

@smhmw Any update ?

@ncruces
Copy link

ncruces commented Nov 11, 2023

I think I came up with a nice API for this in my SQLite driver, which could be implemented for this driver as well:
https://github.com/ncruces/go-sqlite3/blob/main/ext/blobio/blob_test.go

This would require wrapping the pointer passing APIs, on top of blob IO.

PS: the example shows writing/reading a single blob, but it easily supports reading/writing multiple blobs in one go (callback gets called repeatedly for each blob).

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

No branches or pull requests

6 participants