Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've imported a .db file from my android device and I wish to open it using Libreoffice Base or something similarly basic with a simple GUI.

How do I achieve this?

share|improve this question
2  
Type file file.db and paste here the output and what file is it? Name? –  LnxSlck Aug 31 '12 at 13:02
    
bookCatalogueDbExport.db - SQLite 3.x database, user version 78 –  Switchkick Aug 31 '12 at 13:04
add comment

4 Answers 4

up vote 5 down vote accepted

1.Install SQLite browser, it's in the repositories. 1

2.You also have an extension for Firefox (if you use it) - "SQLite Manager"

https://addons.mozilla.org/en-US/firefox/addon/5817/

A list of tools that can manage those files cna be found here

1 - Source

share|improve this answer
add comment

What type of database file is it? The .db extension is not specific to a certain type of database. Though, coming from Android, I presume it's an sqlite database. I don't know of any simple GUIs to browse an sqlite database file, though. Most SQL related tools are far from simple.

share|improve this answer
add comment

From the output of the 'file' command in the comment above I can see that it's an sqlite3 database so all you have to do is open it with the sqlite3 command and export it to CSV. Run the following command:

sqlite3 bookCatalogueDbExport.db

You should see a prompt like this:

sqlite>

If you get an error about "command not found" you'll need to install sqlite3:

sudo apt-get install sqlite3

Verify that sqlite3 can read the database by listing the tables:

sqlite> .tables
books

If you get an error at this point the database is probably encrypted or isn't actually SQLite format (the file command can make mistakes sometimes). If it lists the tables in the .db then you're good to go. Just tell sqlite3 the format you want and have it output all the data:

sqlite> .mode list
sqlite> .separator , -- Comma-Separated (aka CSV)
sqlite> .output books.csv -- Where to save the file
sqlite> select * from books; -- Replace 'books' with the actual table name
sqlite> .exit

Now you should have a file named books.csv that you can open directly with LibreOffice Calc.

Note that sqlite databases can have more than one table. If this is the case you'll want to output each table as its own file. So instead of typing '.exit' above you can continue the process like so:

sqlite> .output some_other_table.csv -- Give it a different name
sqlite> select * from some_other_table; -- Replace 'books' with the actual table name
sqlite> .exit -- When done exporting all the tables

Finally, to be as thorough as possible, here's a link to the sqlite syntax in case you want to play around with it some more:

http://www.sqlite.org/lang.html

share|improve this answer
add comment

This is an old thread, but I came across it today in Google while looking for a solution and found that the full version of Adminer is another alternative that you can use in a web browser to view SQLite DB files: http://www.adminer.org

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.