I'm trying to view my firefox cookies db (cookies.sqlite). Since I've never accessed dbs with anything other than phpmyadmin, I'm at a loss as to how to view the content of this sqlite file. There's localhost/sqlitemanager, but I'd rather stick to the phpmyadmin interface that I'm used to.
Any ideas how I can open/view this sqlite db the normal way in phpmyadmin? Is it possible?
Thanks in advance
P.S. I know that browser cookies are very commonly accessed/played with. If you know another tool that's more specific for this goal, please drop me an answer or suggest in the comments.
There are also several web interfaces for sqlite.
phpSQLiteAdmin
SQLiteManager
Simple SQLite Manager
SQLite Admin
WizSQLiteAdmin
ezSqliteAdmin
SQLiteWebAdmin
knoda
I have not yet tried any of them - in fact, I found this SO question while researching sqlite web front-ends for my own use. But I, too, come from a phpMyAdmin background, so the first one I plan to try is phpSQLiteAdmin.
I imagine there are various GUI programs that will hold your hand. However, I'm going to show you what I would do if I was interested in table moz_cookies in db cookies.sqlite.
$
$ sqlite3 cookies.sqlite
SQLite version 3.5.9
Enter ".help" for instructions
sqlite> .schema
CREATE TABLE moz_cookies (id INTEGER PRIMARY KEY, name TEXT, value TEXT, host TEXT, path TEXT,expiry INTEGER, lastAccessed INTEGER, isSecure INTEGER, isHttpOnly INTEGER);
sqlite> select * from moz_cookies limit 1;
1248713741170186|PREF|ID=12d44375be9e7c86:U=d07dae1b87f4537c:LD=en:NR=100:TM=1248713740:LM=1254091506:FV=2:IG=3:S=Jdo_PXt92J5ojL6E|.google.com|/|1317163505|1255144201180851|0|0
sqlite>
You may want the sqlite3 CLI program. It is available on Unix and Windows.
SQLITE3(1) SQLITE3(1)
NAME
sqlite3 - A command line interface for SQLite version 3
SYNOPSIS
sqlite3 [options] [databasefile] [SQL]
SUMMARY
sqlite3 is a terminal-based front-end to the SQLite library that can
evaluate queries interactively and display the results in multiple for‐
mats. sqlite3 can also be used within shell scripts and other applica‐
tions to provide batch processing features.
DESCRIPTION
To start a sqlite3 interactive session, invoke the sqlite3 command and
optionally provide the name of a database file. If the database file
does not exist, it will be created. If the database file does exist,
it will be opened.
It has two categories of operations.
Commands intended directly for the interactive shell begin with .. Anything is an SQL query terminated as usual with ;.
Adminer is a PHPMyAdmin-like system that has support for MySQL, PostgreSQL, SQLite, MS SQL, Oracle, SimpleDB, Elasticsearch, MongoDB, etc.
Related
I have a huge problem... I am developing desktop app with SQLite but during copy/paste process I lost a power and process was terminated so base was lost. However, I found a way to recover it but base is encrypted. When I try to open connection using conn.Open(); I get this error. If I try to open it with DB Browser for SQLite it asks me a SQLCipher encryption password so it seams to me that data is lost..
Is there any default password ?
Why did this happen and how to prevent it from happening again ?
What can I do ?
Thanks in advance.
Also check that SQLite version you're "connecting" with aligns with the DB file version.
For example, here's a DB file written by SQLite version 3+:
$ file foobar.db
foobar.db: SQLite 3.x database, last written using SQLite version 3027002
And here I also have 2 versions of sqlite:
$ sqlite -version
2.8.17
$ sqlite3 -version
3.27.2 2019-02-25 16:06:06 bd49a8271d650fa89e446b42e513b595a717b9212c91dd384aab871fc1d0alt1
Obviously in hindsight, opening foobar.db with sqlite version 2 will fail, yielding the same error message:
$ sqlite foobar.db
Unable to open database "foobar.db": file is encrypted or is not a database
But all is good with the correct version:
$ sqlite3 foobar.db
SQLite version 3.27.2 2019-02-25 16:06:06
Enter ".help" for usage hints.
sqlite>
sqlite> .databases
main: /tmp/foobar.db
sqlite>
The error message is a catch-all, simply meaning that the file format was not recognized.
Ok, finally found a solution that works so posting the answer if anybody will have same trouble as I did..
First of all, use good recover software. For repairing the database I found 3 solutions that work without backup :
Open corrupted database using DB Browser an Export Database to SQL. Name it however you want. Then, create new database and import database from SQL.
There is software that repairs corrupted databases. Download one and use it to repair the database.
Download "sqlite3" from sqlite.org and in command line navigate to folder where "sqlite3" is unzipped. Then try to dump the entire database with .dump, and use those commands to create a new database:
sqlite3 corrupt_table_name.sqlite ".dump" | sqlite3 new.sqlite
I had the same error when I was trying to access a db dump in another system compared to compared to where it was obtained. When I tried to open on a dev machine, it threw the reported error in this thread:
$ sqlite3 db_dump.sqlite .tables
Error: file is encrypted or is not a database
This turned out to be due to the differences in the sqlite version between those systems. This dev system version was 3.6.20.
The version on the production system was 3.8.9. Once I had the sqlite3 upgraded to same version, I was able to access all its data. I am just showing below the tables are displayed as expected:
# sqlite3 -version
3.8.9
# sqlite3 db_dump.sqlite .tables
capture diskio transport
consumer filters processes
This error is rather misleading to begin with, though.
If you've interacted with the database at some point while specifying journal_mode = WAL, and then later try to use the database from a client that does not support WAL (< v3.7.0), this error can also come up.
As noted in the SQLite documentation under Backwards Compatibility, to resolve that without having to recreate the database, explicitly set the journal mode to DELETE:
PRAGMA journal_mode=DELETE;
Your database did not become encrypted (this is only one of the two options in the error message).
Your data recovery tool did not recover the correct data; what you have in the file is something else.
You have to restore the database file from the backup.
The issue is with sqlcipher version upgrade in my case, Whenever I update my pod it automatically upgrade the sqlcipher and the error occurred.
For a quick fix just manually add the SDK instead of Pod install. And for a proper solution use this link GitHub Solution
I'd like to know how the .dump command affects other applications connected to the same database. I'd like to know this for the following journal modes:
DELETE (the default mode)
WAL (write-ahead-logging)
From reading other posts on this forum .backup uses the online backup API of SQLite. It would be great to have this confirmed as well.
Thanks in advance!
The .dump command reads the contents of the database normally, just as if you would do a bunch of SELECT queries inside a transaction.
This means that when not using WAL, other connections cannot write as long as the dump is running.
I am trying to open a very large dataset in SQLite. It has no extension. Now I cannot open it in SQLite. How can I do it? What will be the command and where should I place that dataset file?
I searched over the net but couldn't get the appropriate command for the opening and viewing the dataset.
SQLite does not have datasets, it has databases. Command line tool to operate on databases is sqlite3, it will open SQLite database even if it does not have an extension, but it must be valid SQLite database, that is, it should have string SQLite Format 3 as first bytes in database file.
In other words, use this:
sqlite3 yourdatabase
sqlite> .tables
a b c
sqlite> SELECT * FROM a LIMIT 10
...
You can also use numerous SQLite tools and libraries for different programming languages like C/C++, Java, Perl, Python, etc. to access that database.
I have used SQLIte3 to create databases and then added tables to it. Then i closed the terminal and reopened it.
I typed the command sqlite3, and typed select * from tableName; It says the table is not found.
Think i have to select the database first and then type the above select statement to work. So how can i do that ?
SQL commands like show databases; is not recognized.
You have to write sqlite3 DB_NAME on terminal to open database. Then you can see sqlite prompt like sqlite3> You can enter command select * from tableName there, so that your tables will be listed. You can also try .schema command to see the schema of your data base. Refer the site http://www.sqlite.org/ for more details.
You can use SQLite Manager firefox add-on to view sqlite database, table and execute query there.
Is there any way to get a SQLite view on a JSON file?
Thanks
On recent versions of SQLite, this is built in. The following:
sqlite3> .mode json
sqlite3> .once out.json
sqlite3> SELECT * from foo;
writes the table foo to out.json.
Or, directly from the command line:
sqlite3 db.sqlite3 '.mode json' '.once out.json' 'select * from foo'
.once, which writes the output of the next SQL command to the indicated file, has been in SQLite since 3.8.5 in 2014.
The .mode json is newer though, added in 3.33.0 in 2020-08. It comes with ubuntu 20.10 but older operating systems are unlikely to have that feature in their built-in SQLite version.
SQLiteStudio (sqlitestudio.pl) can export from sqlite3 database to JSON. SQLiteStudio is C++ Qt-based, open source GPLv3 licensed, Linux/macOS/Windows application with a git repository here: 'pawelsalawa/sqlitestudio'.
There are certainly ways to do this. For example, you could write a custom program that parses the JSON input via your favorite JSON processor and then generate the equivalent SQL statements to create tables, insert the rows, etc. and then import that into a SQLite capable tool (DB Browser for SQLite) to generate the actual SQLite db file.
I suspect you will be hard pressed to find a general purpose tool to accomplish this, as the content of the JSON input could vary widely, and in fact may not map well into a relational database at all.