Sqlite Error: file is not a database

馋奶兔 提交于 2020-11-27 07:54:21

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!