Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sqlite Error: file is not a database

Tags:

sqlite

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?

like image 407
user7441 Avatar asked Feb 25 '18 13:02

user7441


2 Answers

The error can occur when a database was created with cipher.
So sqlite3_open succeded but any sqlite3_exec or sqlite3_prepare will be failed with this error.

like image 147
Aikon Mogwai Avatar answered Nov 18 '22 11:11

Aikon Mogwai


Create database without the .db extension.
for e.g. sqlite3 users //this creates a database names users

like image 37
user7441 Avatar answered Nov 18 '22 12:11

user7441