How to open SQLCipher passwrd protected file in Datagrip
Hi,
how can I open an SQLCipher password protected database file?
Datagrip does not give me an option to use a password.
At the moment I am forced to use SQLite Studio.
Thanks for your help.
Arthur
Please sign in to leave a comment.
Hello Arthur,
Let's try this:
Please download sqlite-jdbc-3.31.1.jar from https://github.com/Willena/sqlite-jdbc-crypt/releases
Go to DataGrip, File -> New -> Driver, name it like 'SQLCipher', add to 'Driver files' recently downloaded package, add to 'URL templates' something like
default jdbc:sqlite:!(:memory:){file::identifier.sqlite}?{password}
(you can see examples in native SQLite driver)
Go to "Options" tab and set Icon and Dialect to 'SQL lite'. Click Apply.
Now you can add Data Source of that type. Probably you will need to play around with parameters in connection URL.
Let me know the results.
Best regards,
Yuri
Hi Yuriy
I follow your steps, I still can not open SQLCipher password protected database file.
The error message is "[26] [SQLITE_NOTADB] File opened that is not a database file (file is not a database)."
let's try this - open SSH/SSL tab, check 'use SSL' and try again.
I check "use SSL" but still can not open it.
The error message is "[26] [SQLITE_NOTADB] File opened that is not a database file (file is not a database)."
I don't have CA file, Client certificate file, Client key file. I only have database's password.
BTW, the database file is from my developed App. The App use SQLCipher plugin to protect database file.
Hi Alan, did you find a solution to the problem with the password protected SQLcipher Database connection in Datagrip?
No, I don't find a solution. But I use DB Browser for SQLite to open Database with the password protected.
I got it to work with the sqlite-jdbc-crypt https://github.com/Willena/sqlite-jdbc-crypt driver and the following connection string:
If you click on "Test connection" it should successfully open the database. In case the provided key is wrong it fails with "[26] [SQLITE_NOTADB] File opened that is not a database file (file is not a database)."
Hope this helps.
Yuriy Vinogradov , Bernhard Caspar thank you, the guide helped.
I use sqlcipher v3 encrypted databases, so I also had to set parameter legacy=3 and cipher=sqlcipher. It can be passed in URL
or be set in Advanced card
https://github.com/Willena/sqlite-jdbc-crypt#aes-256-bit-cbc---sha1sha256sha512-hmac-sqlcipher
This really should be built-in by now, JetBrains... Here's what I did in my case to get it working (in case it helps anyone):
In my case, I need to open a SQLIte encrypted DB created using C#, .NET 7, and EF. I used SQLitePCLRaw.bundle_e_sqlcipher for the encryption.
In DataGrip, I used the driver from sqlite-jdbc-crypt (https://github.com/Willena/sqlite-jdbc-crypt/releases). I used the following URL format for the connection string in DataGrip:
So it's similar to what others have stated above, just wanted to tell everyone of one other possibility.
I had to use is this way, since I had a password as byte[] array, and DB file was from dot net. First converted each byte to HEX, and then used it as such (e.g. HEX is `FFFFABC` in this example):
<data-source source="LOCAL" name="SQLCipher" uuid="">
<driver-ref>java.sql.Driver</driver-ref>
<synchronize>true</synchronize>
<configured-by-url>true</configured-by-url>
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
<jdbc-url>jdbc:sqlite:file:$USER_HOME$/Some/Folder/MyDatabase.db</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
<driver-properties>
<property name="cipher" value="rc4" />
<property name="legacy" value="1" />
<property name="busy_timeout" value="3000" />
<property name="date_string_format" value="yyyy-MM-dd HH:mm:ss.SSS" />
<property name="legacy_page_size" value="0" />
<property name="shared_cache" value="false" />
<property name="hexkey_mode" value="SSE" />
<property name="open_mode" value="70" />
<property name="transaction_mode" value="DEFERRED" />
<property name="date_precision" value="MILLISECONDS" />
<property name="date_class" value="INTEGER" />
<property name="key" value="FFFFABC" />
</driver-properties>
</data-source>
I succeed with Yuriy Vinogradov's solution. But, in my case, additionally I needed to add
slf4j-api-1.7.36.jar
file(which is mentioned on the Usage part of the sqlite-jdbc-crypt) to the Driver Files list. After added the file path, I can selectorg.sqlite.JDBC
class and connect to db with “jdbc:sqlite:/path/to/db?cipher=sqlcipher&key={key phrase}&legacy=4” this url format (Actually i didn't set the url templates)I hope my comments can help save your time.