-
-
Notifications
You must be signed in to change notification settings - Fork 117
Adding a "recreate" flag to the Database
constructor
#97
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
Comments
Interesting thought. I've run into this myself a lot - many of my scripts intend to create the database from scratch, so I end up running I think adding |
I wonder if it should delete an recreate the file or if it would be safer to drop every table instead? Dropping tables gets messy: then you need to drop triggers and views, and you need to run My worry with deleting and recreating the file is that it could trigger errors in other processes that are currently attached to that database file. But... if you know that's going to be likely, maybe you shouldn't use the |
Woah! Thanks a lot. Next time I will add a more obvious/explicit "if you like this idea let me know I'd love to work on it to get my feet wet here" :D |
I have a script that imports data into a sqlite DB. When I re-run that script I'd like to remove the existing sqlite DB, instead of adding to it. The pragmatic answer is to add the check and file deletion to my script.
However I thought it would be easy and useful for others to add a
recreate=True
flag todb = sqlite_utils.Database("binder-launches.db")
. After taking a look at the code for it I am not so sure any more. This is because the connection string could be a URL (or "connection string") like"file:///tmp/foo.db"
. I don't know what the equivalent ofos.path.exists()
is for a connection string or how to detect that something is a connection string and raise an error "can't use recreate=True and conn_string at the same time".Does anyone have an idea/suggestion where to start investigating?
The text was updated successfully, but these errors were encountered: