"Error: Unable to Open Database" When Creating Sqlite3 Database in Terminal

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

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

Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest