I'm completely new to Qt. Actually I'm trying to build an app, which stores it's data to an encrypted sqlite database file. Ok, I've build sqlcipher successfully and found the files under ./libs (I'm on a Mac).
Where do I've to put the files in my Qt project for development, and later on, for deploy it with the app?
qDebug() << QSqlDatabase::drivers();
gives me
("QSQLITE", "QMYSQL", "QMYSQL3", "QODBC", "QODBC3", "QPSQL", "QPSQL7")
Thanks in advance.
I don't think a driver for SQLCipher exists in Qt. You'll only get the default drivers, which include SQLite.
I know two options: you use sqlcipher with its C API like a normal library, link to your app and you're done. Or you create the driver yourself. Creating that driver should be pretty simple as it should be almost identical to the one for sqlite, being the API almost identical. Simply linking the sqlite driver to sqlcipher instead of sqlite should be enough.
I found this online that should help you. But there are probably also other useful resources. That seems to simply re-use the sqlite plugin, linking to sqlcipher.
Related
I am writing a installer for windows using NSIS. The installer gets few properties during installation and it needs to update one of the table in sqlite database that is bundled with the installer. Is it possible to update sqlite database file using NSIS?
It does not seem like there are any SQLite plugins.
Your options are:
Write your own plugin (included for completeness, but almost certainly not a real option)
Use nsExec to run SQLite commands via the command line interface. See discussion on NSIS forums
Write a small app to include with your installer that makes the required changes
Decision probably depends on how well you know the command line interface for SQLite vs. complexity of writing a small app to do what you want.
For #3, it would be similar to what you would do with a third party installer:
ReserveFile "myexe.exe"
...
SetOutPath $TEMP
File "myexe.exe"
ExecWait '"$TEMP\myexe.exe" /parameters"
alt option: http://sourceforge.net/projects/nsissqliteplug/
nsisSqlplugin::executeQuery "sqliteDatabase" "sql_query"
Limitations:
Currently the plugin executes only insert and update queries.
I've played around with SQLite on my Windows desktop before, but I've never used it in a web context and their web documentation is maddenigly unspecific about things like this. Essentially, I have free student webspace from my school (a /public/html/ directory) and I'd like to use it for a small data-driven web project. SQLite is my only (free) option and I'm wondering how to... "install" it in this context? More specifically, is it safe just to throw the files in the html directory and call it a day?
If it helps, I'm pretty sure it's Linux environment (they run Apache).
See if it's already installed. Try the following in a bash session:
touch test.db
sqlite3 test.db
If not, you'll have to download and install sqlite3.
Useful tip: if you've been trying to run the 'sqlite' binary, it probably doesn't exist. It's called 'sqlite3'.
SQLite is an embedded database; it is typically not installed, but compiled into whatever program is used to access the database.
All the typical server-side extension languages (PHP, Ruby, Python, Perl etc.) have support modules for SQLite.
You have to check which one of those are installed on the server, and whether SQLite support has been enabled for them.
I'm working on a node.js project and I would like to use some kind of database to store application data. I've searched for various DBMS and I've selected SQLite because I want my project to be able to run without installing heavy DBMS and because I want it to run both on linux and windows. however, all modules that we found, that connect node with SQLite are either very old, or cannot be installed due to bugs.
so, I want to ask if nowadays, 2012, there is a completely functional node.js module for SQLite.
I did a project last July (2012) in Node.JS v0.8.8, using the node-sqlite module (see https://github.com/developmentseed/node-sqlite3) and it worked just fine.
And, I successfully deployed and used this module on Heroku. However, the deployed portion of the project only involved reading out of the SQLite database – not writing. I suspect that writing into a SQLite deployed on Heroku would cause some issues, because it involves modifying the SQLite file in the file system, which AFAIK Heroku doesn't let you do.
I have a Monotouch app which uses a sqlite database. I want to encrypt the database so I am doing this:
_mainConnection = new SqliteConnection("Uri="+finalDB);
_mainConnection.Open();
_mainConnection.ChangePassword("mypassword");
However, its not working (on simulator and iphone). It gets this error:
at (wrapper managed-to-native)
Mono.Data.Sqlite.UnsafeNativeMethods.sqlite3_rekey
(intptr,byte[],int) <0x0005c> at
(wrapper managed-to-native)
Mono.Data.Sqlite.UnsafeNativeMethods.sqlite3_rekey
(intptr,byte[],int) <0x0005c> at
Mono.Data.Sqlite.SQLite3.ChangePassword
(byte[]) <0x00053> at
Mono.Data.Sqlite.SqliteConnection.ChangePassword
(byte[]) <0x0004b> at
Mono.Data.Sqlite.SqliteConnection.ChangePassword
(string) <0x0005b>
Has anyone successfully used password protection on an sqlite database in Monotouch?
As per my research there are a few options for database encryption using MonoTouch. I have a forthcoming blog post on the subject, but for now these are your top two options:
SQLCipher
I've automated the SQLCipher build process substantially. All it takes is a simple make command and you've got a library that you can link into your project. It makes use of the awesome SQLite-NET library. After that, all that's required is to provide the key in the SQLite.cs file.
SQLCipherNet: https://github.com/anujb/SQLCipherNet
CSharp-SQLite
This is a managed port of the SQLite library in C#. Performance is only about ~2x slower, which is pretty awesome considering it's not native code!
Encryption: http://code.google.com/p/csharp-sqlite/wiki/ENCRYPTION
Perf Benchmarks: http://code.google.com/p/csharp-sqlite/wiki/Benchmarks
Try adding ";Password=mypassword" to your connection string, and remove the call to ChangePassword.
Please note that, by default, the iPhone implementation of sqlite does not support encryption, so the sqlite commands for that will be no-ops.
You can get a (paid) copy of the encrypt-able version of sqlite from http://www.hwaci.com/sw/sqlite/see.html, and compile it into your application, making sure to remove the libsqlite3*.dylib from your project if you've linked that in.
You may have to do a bit of digging in the Monotouch documentation and/or experimentation to make sure that the Monotouch library itself is not including the default sqlite implementation, but in fact links to the implementation you specify. Try it first, if things still don't work that's where I'd start looking.
You can do this experiment without paying for the encrypted version, simply using the sqlite3 source code available on the net, with appropriate break points.
Good luck!
PS: Note that there is no comparable solution for Android at this point, this works on iPhone because iPhone runs native C code.
PPS: There is also SQLCipher that claims to encrypt sqlite on iPhone. However I found the configuration requirements to be below my standards for simplicity. I'm also not sure if it will properly insert itself between Monotouch's framework code and the default iPhone sqlite implementation.
SQLCipher for MonoTouch provides full database encryption for SQLite databases.
http://sqlcipher.net/sqlcipher-for-monotouch
There is also a SQLCipher on Mono for Android, which allows you to reuse the same code across Mono Touch and MonoDroid applications
http://sqlcipher.net/sqlcipher-for-monodroid
Just thinking out loud but could this be due to sqlite's dynlib that comes with the iPhoneSDK not being threadsafe?
For an alternative you might try looking at WWDC Vid 209 and just lock/encrypt the DB when you're outside the app.
You can probably do it yourself by issuing a "pragma rekey" in a raw SQLite query -- that is, if the SQLite version installed is actually SqlCipher.
I had the same problem but with a windows form application in C#.
I could not find the solution so i had to encrypt my data manually when saving it and decrypt it when retrieving.
I've tried passing binary SQLite DBs over the network between different OSes and architectures - it didn't work.
What format are you all using? I've tried an unholy hack of copying SQLite's shell.c and calling shell_main() with a hacked up argc, argv, stdin with success on Mac. Pity I'm developing for the iPhone and it fails only there.
Does everyone do such awful things?
This is one of the core features of SQLite.
Stable Cross-Platform Database File
The SQLite file format is cross-platform. A database file written on one machine can be copied to and used on a different machine with a different architecture. Big-endian or little-endian, 32-bit or 64-bit does not matter. All machines use the same file format. Furthermore, the developers have pledged to keep the file format stable and backwards compatible, so newer versions of SQLite can read and write older database files.
Most other SQL database engines require you to dump and restore the database when moving from one platform to another and often when upgrading to a newer version of the software.
http://sqlite.org/different.html
Check the code that's passing the databases. Do a byte-by-byte comparison to make sure they're equal after transfer. This definitely should be working.
Beyond Compare has good binary file comparison support.