Opening a database ReadWrite but not Create #1074
blackskye-sx
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am writing this for someone else who might be researching this issue.
I wanted to create a connection that would ERROR when the database file was not already there. The default for sqlite and sqlite-jdbc is to create the database automatically.
Most reasonable people would probably just create a test first to see if the file is there which makes sense, but SQLite does have a way of erroring.
The default open mode for sqlite-jdbc and the C interface is ReadWrite and Create. I wanted to turn off that Create. For connections through C interface, you would use "mode=rw" and avoid "mode=rwc". https://www.sqlite.org/c3ref/open.html
For sqlite-jdbc, use SQLiteConfig.resetOpenMode(SQLiteOpenMode.CREATE) to turn OFF the Create bit.
Beta Was this translation helpful? Give feedback.
All reactions