Open mtlynch opened 7 months ago
Hi!
Do you intend to use both drivers together, or port to my driver?
Using two different instances/versions of SQLite in the same process is a really bad idea. Due to the way POSIX locking works it can easily lead to data corruption, missed updates, etc.
Hey, @ncruces! Nice surprise that you found this! Thanks for your work on your driver.
Do you intend to use both drivers together, or port to my driver?
Using two different instances/versions of SQLite in the same process is a really bad idea. Due to the way POSIX locking works it can easily lead to data corruption, missed updates, etc.
I'm trying to port entirely over to your driver.
The issue I'm running into is that I only need a SQLite-specific API in one spot. Everywhere else, I'd like to continue using the generic databases/sql
API.
What would you recommend for this scenario?
Good that you're not trying to mix drivers. That's a little known SQLite pitfall.
I would recommend you use the writeblob
function from the blobio
extension. See an example.
You can bind an io.Reader
by replacing message
in this line with sqlite3.Pointer(reader)
.
The reader will be copied to the blob.
The blobio
extension can similarly be used to “stream” blobs from the database. That's also in the example.
@ncruces - Thanks so much! I'll give it a shot.
No problem.
Heads up, I'll be improving the extension on the next release: https://github.com/ncruces/go-sqlite3/commit/356dd56e5f1d79c3dec914cb981e9cea362608f9
Writing the blob with writeblob
is essentially unchanged; reading can now be done simpler with readblob
; openblob
stays for more advanced scenarios.
Resolves #566
Current status (2024-09-10): Code works locally, fails in e2e and some unit tests