Trouble exporting (and then importing) .db files correctly in SQLiteStudio

34 views Asked by At

I created it the database SQLite Studio and need to export it into a db file. But this always pops up. It says: It cannot be exported to the file XXtest7. The file cannot be opened for write access.

Hello,

I have a problem exporting my database. I created it on SQLite Studio and need to export it into a db file.

But this always pops up. It says: It cannot be exported to the file XXtest7. The file cannot be opened for write access.

I have to sumbit it today so I am thankful for any help. Thank you in advance!

1

There are 1 answers

0
MikeT On

Instead of exporting simply save the file, make a copy with whatever file name you wish.

An SQLite database is a single file (assuming the database has been closed) and it can be copied renamed. SQLite itself manages the file (or files).

  • If Write Ahead Logging is used then the -wal file, if it exists (it shouldn't if the main file has been closed correctly) then that file is part of the database. see https://www.sqlite.org/wal.html

Exporting is extracting the data from the database in another format (as allowed by the tool's options) it will NOT be an SQLite Database file.


As a simple example:-


  1. A new database is added location being .../SQliteStudio Databases/mydatabase.sqlite.
  2. A single table name mytable with 2 columns is created:- enter image description here
  3. the connection is closed and the file is saved as mydatabase.sqlite and the connection re-opened. 4.Tool/Export is used for types HTML,JSON,SQL and XML (e.g. for XML):- enter image description here
    1. Note the file path and the new file name
  4. After closing the connection (to fully commit the WAL file should it exist) then file explorer is used to copy the file, paste it and rename the pasted file to XXTest7.xxx.
    1. all files have been saved to the same directory folder
  5. In Windows Explorer:- enter image description here
  • The first file mydatabase.sqlite is the actual sqlite database file as created and maintained by SQlite Studio
  • XXTest7.xxx is the copied and renamed version of the file.
  • XXTest7_exported.html is the export using HTML and looks like:- enter image description here
  • XXTest7.JSON :- enter image description here
  • XXTest7.sql :- enter image description here
  • XXTest7.xml` :- enter image description here

SO the EXPORTED files are just files that could be imported into an sqlite database given an appropriate tool to do so.

Files mydatabase.sqlite and XXTest7.xxx if opened using NotePad++ looks like:- enter image description here not of much use.

However if opened via SQLite (either a tool or via the SQLite programming interface) the database is as per the original. e.g. Connecting to the XXTest7.xxx file using DBeaver results in :- enter image description here