问题
I have created a database named database.db
When I create a table in the database I get the error:Error: file is not a database
nehal@nehal-Inspiron-5559:~/Desktop/UAV$ sqlite3 database.db
SQLite version 3.20.1 2017-08-24 16:21:36
Enter ".help" for usage hints.
sqlite> CREATE TABLE users(
...> password varchar(10),
...> email text,
...> name text
...> );
Error: file is not a database
How do I resolve the error?
回答1:
Create database without the .db
extension.
for e.g. sqlite3 users //this creates a database names users
回答2:
You can also use
.open users
it will also create the database
and to open an existing database users.db use
.open users.db
if .db is not used new database of same name will be created
来源:https://stackoverflow.com/questions/48974135/sqlite-error-file-is-not-a-database