You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enhance sqlite3 to avoid implicit creation? #90560
The sqlite3 library implicitly creates the database if the requested file doesn't exist. I would like to be able to avoid that implicit creation. (Actually, it would be enough to know whether I had created the database, but the underlying SQLite library doesn't seem to indicate that.)
The C code currently hard-codes the SQLite flag to create the database if it doesn't exist:
Activity
nedbat commentedon Jan 16, 2022
The sqlite3 library implicitly creates the database if the requested file doesn't exist. I would like to be able to avoid that implicit creation. (Actually, it would be enough to know whether I had created the database, but the underlying SQLite library doesn't seem to indicate that.)
The C code currently hard-codes the SQLite flag to create the database if it doesn't exist:
Could we make this an option, so the Python code could avoid implicit creation?
ericvsmith commentedon Jan 16, 2022
I agree that would be a useful option.
erlend-aasland commentedon Jan 17, 2022
FYI, you can already do this using the URI option:
erlend-aasland commentedon Jan 17, 2022
See also bpo-24887.
erlend-aasland commentedon Jan 17, 2022
IMO, the URI "API" is not very pythonic; I have to look up the format every time I'm using it.
OTOH, introducing flags, or keywords, for every option will add a lot of code.
erlend-aasland commentedon Jan 17, 2022
OTOH, implementing an API similar to apsw (adding a flags keyword) would make it easier for users to switch between that and the stdlib sqlite3.
nedbat commentedon Jan 17, 2022
@erlend: thanks for the URI tip, I missed that as a possibility in the SQLite docs.
erlend-aasland commentedon Jan 17, 2022
I guess we could do more to promote that trick in the docs. It’s quite useful.
erlend-aasland commentedon Jan 18, 2022
I created #74845 in order to try to enhance the docs. Ned and Eric, would you mind taking a look at the PR?
ericvsmith commentedon Jan 18, 2022
New changeset bdf2ab1 by Erlend Egeberg Aasland in branch 'main':
bpo-46402: Promote SQLite URI tricks in
sqlite3docs (GH-30660)bdf2ab1
nedbat commentedon Jan 18, 2022
BTW, I'm fine with this being closed, since the functionality I wanted is available and documented.
erlend-aasland commentedon Jan 18, 2022
Great. I was considering closing it as soon as the backports have landed (I had to manually fix them bco. make suspicious failures).
ericvsmith commentedon Jan 18, 2022
New changeset 01e6cbe by Erlend Egeberg Aasland in branch '3.10':
[3.10] bpo-46402: Promote SQLite URI tricks in sqlite3 docs (GH-30660) (GH-30671)
01e6cbe
ericvsmith commentedon Jan 18, 2022
New changeset 0ae2257 by Erlend Egeberg Aasland in branch '3.9':
[3.9] bpo-46402: Promote SQLite URI tricks in sqlite3 docs (GH-30660) (bpo-30672)
0ae2257
erlend-aasland commentedon Jan 18, 2022
Closing this. Thanks, Ned and Eric!