M HYPE SPLASH
// updates

"Error: unable to open database" when creating sqlite3 database in terminal

By John Campbell

The other questions I've seen deal with this have to do with creating databses through Django or some other Python framework. I am simply trying to create a database with $sqlite3 database.db. It opens up the sqlite console, but when I type .schema, I get Error: unable to open database "database.db": unable to open database file, and then get booted from the database. There's no database.db file leftover.

I cannot make sense of this.

2

1 Answer

A database file is not created until you actually add table(s). Try adding a table using:

sqlite> create table [table name]([field] [type]);
sqlite> .quit

Then you should have a database file created.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy