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

Replace sqlite3 driver with ncruces version #567

Draft
wants to merge 59 commits into
base: master
Choose a base branch
from
Draft

Conversation

mtlynch
Copy link
Owner

@mtlynch mtlynch commented May 1, 2024

Resolves #566


Current status (2024-09-10): Code works locally, fails in e2e and some unit tests

@ncruces
Copy link

ncruces commented Sep 4, 2024

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.

@mtlynch
Copy link
Owner Author

mtlynch commented Sep 4, 2024

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?

@ncruces
Copy link

ncruces commented Sep 4, 2024

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.

@mtlynch
Copy link
Owner Author

mtlynch commented Sep 4, 2024

@ncruces - Thanks so much! I'll give it a shot.

@ncruces
Copy link

ncruces commented Sep 5, 2024

No problem.

Heads up, I'll be improving the extension on the next release: ncruces/go-sqlite3@356dd56

Writing the blob with writeblob is essentially unchanged; reading can now be done simpler with readblob; openblob stays for more advanced scenarios.

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

Successfully merging this pull request may close these issues.

Try ncruces/go-sqlite3
2 participants