File is not a database как исправить

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?

asked Feb 25, 2018 at 13:44

user7441's user avatar

5

Create database without the .db extension.

for e.g. sqlite3 users //this creates a database names users

answered Feb 25, 2018 at 16:58

user7441's user avatar

user7441user7441

4012 gold badges5 silver badges11 bronze badges

5

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.

answered Feb 2, 2021 at 0:00

Aikon Mogwai's user avatar

Aikon MogwaiAikon Mogwai

4,8442 gold badges18 silver badges30 bronze badges

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

answered Nov 10, 2019 at 5:45

Devanshu's user avatar

DevanshuDevanshu

87310 silver badges22 bronze badges

Same problem with WPF and SQLiteAdministrator creating a SQLite v3 DB with Database->New->SQLite 3 DB option and “Data Source=whatever.s3db; Version=3” in the WPF code using System.Data.SQLite library.

Select Database->Migrate to SQLite3 option in SQLiteAdministrator solves the problem. Its works for me. I hope this helps someone.

answered Mar 29, 2022 at 15:10

realcnk's user avatar

Comments

@mtissington

@justinclift
justinclift

added
the

bug

Confirmed bugs or reports that are very likely to be bugs.

label

Mar 23, 2019

MKleusberg

added a commit
that referenced
this issue

Mar 25, 2019

@MKleusberg

When opening a plain database and trying to attach an unencrypted
database we need to explicitly specify that there is no key for the
attached database. Otherwise SQLCipher is going to use the same key as
for the main database which results in an error.

See issue #1814.

MKleusberg

added a commit
that referenced
this issue

Mar 30, 2019

@MKleusberg

When opening a plain database and trying to attach an unencrypted
database we need to explicitly specify that there is no key for the
attached database. Otherwise SQLCipher is going to use the same key as
for the main database which results in an error.

See issue #1814.

Summary: This blog is summarized about the methods to resolve  SQLite encryption error. Sometimes, we face a lot of errors during the operation of the SQLite database. But the SQLite encryption error is very common and the message shows like this:
“Fixed SQLite Error – file is encrypted or is not a database”

So, if you reluctantly getting this error and looking forward to a genuine solution to fix this encryption error then, you are in the right place to resolve this error. This is the most common error SQLite users face. Now, before going for the solution let’s have a look at a brief description of the SQLite database.

Introduction to SQLite

SQLite is a lighter version of the SQL database and widely deployed database in the world of application. It is different from the other SQL databases like it does not require a separate server process. And it directly performs reads and writes operations to ordinary disk files. In a single file, a whole SQL database is included containing multiple tables, indices, triggers, and views. The codes of SQLite are in the public domain by which it is widely used in personal and professional work.

Now here I am going to mention some more features, which makes it exclusive from other database engines.

Features of SQLite Database

  1. It does not require a separate server process, not like other SQL databases.
  2. The SQLite has a feature to directly read and write to ordinary disk files.
  3. This Database has ways to create, delete, execute SQL commands, and perform other common database management operations.
  4. Mostly the SQLite source code is meant for testing and verification.
  5. The SQLite is embedded in the end program. Its database engine is not a client-server.

Causes of SQLite File is Encrypted or is Not a Database Error

The two major reasons are responsible for the situation when the SQLite file is encrypted or is not a Database. These reasons are as follows:

  1. Maybe the data file is not password protected.
  2. SQLite is a sequential database which consists of a minimum of one table and one record. So error occurs when you have created a file as a new file in which it is out of the table.

Troubleshooting this SQLite Encryption Error Manually

  1. Install the SQLite3 Database:
    >> sudo apt-get update
    >> sudo apt-get install sqlite3 libsqlite3-dev
  2. Under the install documentation there is an error there when determining database file in etc/turnserver.conf:
    userdb=/etc/turnuserdb.conf
    should be changed to:
    userdb=/var/lib/turn/turndb
    PS:
    In case of need of the main parts of turnuserdb.conf:
    # you can listen ports 80 and 443 instead of 3478/5349
    listening-port=3478
    alt-listening-port=0tls-listening-port=5349
    alt-tls-listening-port=0listening-ip=YourPublicIPv4
    relay-ip=YourPublicIPv4
    external-ip=YourPublicIPv4# realm=yourdomain.com
    # server-name=yourdomain.com# lt-cred-mech
    # userdb=/etc/turnuserdb.conf OAuth
    user=youruser: your password# use real-valid certificate/privatekey files
    # cert=/etc/ssl/certificate.pem
    # pkey=/etc/ssl/private.keyno-stdout-log

Automated Method

As we all can see the manual way is very complex and need deep knowledge to perform these steps. Hence, It is advisable to try a third-party tool like SysInfoTools SQLite Repair software to get rid of these complex errors in very easy steps. The software is inbuilt with a result-oriented algorithm that performs SQLite database recovery perfectly.

Conclusion

In the above section, we have discussed the manual and automated approaches to resolve SQLite encryption error. The manual method needs technical knowledge and is not suitable for a novice user, whereas using a third-party tool makes it easier and output-driven way. Anyway, you can choose any method which is suitable for you and if are having any suggestions for us please mention them in our comment section.

Know why you get SQLITE File is encrypted or is not a database message

In this technical blog, we first introduce you to a SQLite sample database. Then, we will give you the links to download the sample database and its diagram. At the end you will know how to connect to the sample database using the sqlite3 tool.

SQLite is a popular choice as embedded database software for local/client storage in application software such as web browsers.
SQLite is also said to be a unique in-process library that is a self-contained, zero-configuration, server less, transactional SQL database engine. The code for SQLite is in the public domain and is thus free for use for any purpose, commercial or private.

Additionally, it do not possess a separate server process unlike most other SQL databases. SQLite also have the ability to read and write directly to ordinary disk files. SQLiteDatabase has methods to create, delete, execute SQL commands, and perform other common database management tasks. Most of the SQLite source code is devoted purely to testing and verification SQLite is not a client–server database engine. Rather, it is embedded into the end program.

Recently lots of user are getting message that SQLITE File is encrypted or is not a database. what is this?

This problem arises because of two things.

Either the data file is not password protected and (2)it is a sequalize database that contains at least one table and one record.

The error happens because you create a file as a new file and then out of the table. This method is completely valid but it creates a database as version two.

To resolve the issue follow the below mentioned tips.

1) Install SQLite3:
>> sudo apt-get update
>> sudo apt-get install sqlite3 libsqlite3-dev

2) In the install documentation you will find an error there when defining database file in etc/turnserver.conf:
userdb=/etc/turnuserdb.conf
should be changed to:
userdb=/var/lib/turn/turndb

PS:
Here are some important parts of turnuserdb.conf in case you need:
# you can listen ports 80 and 443 instead of 3478/5349
listening-port=3478
alt-listening-port=0


tls-listening-port=5349
alt-tls-listening-port=0


listening-ip=YourPublicIPv4
relay-ip=YourPublicIPv4
external-ip=YourPublicIPv4


# realm=yourdomain.com
# server-name=yourdomain.com


# lt-cred-mech
# userdb=/etc/turnuserdb.conf

oauth
user=youruser:yourpassword


# use real-valid certificate/privatekey files
# cert=/etc/ssl/certificate.pem
# pkey=/etc/ssl/private.key


no-stdout-log
Consider using your YourPublicIPv4 (x.x.x.x) and youruser:yourpassword.

Conclusion: Further if the problem still persist then do use the SQLite Database protection software by Aryson SQLite Recovery. In today’s time this software is much in demand because of its requirement and effective solution. The software resolve all the issue easily by clicking on few option.

Related Post

Добрый день.
У меня имеется начальное веб приложение, и мне потребовалось создать базу данных через SQLAlchemy + sqlite3
При запуске веб-приложения, ошибок никаких не выдает, создается файл (mydatabase.db), в классе присутствует пару колон по типу: емаил, пароль.
в терминале ввожу sqlite3 mydatabase.db
После ввожу Select * from mydatabase.db;
и выдает такую ошибку: “Error: no such table: Users”
Но если я открываю базу напрямую, то там имеются все колонки.
Пробовал менять и название класса, и название базы, ничего не помогло.
5dc2872a9e3fa330684917.png
5dc2873be82a1900378276.png
WXKJIDc1Hfg.jpg
X371AOTJPr8.jpg


  • Вопрос задан

    более трёх лет назад

  • 1104 просмотра

Добавить комментарий