Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
aminroosta committed Feb 17, 2017
1 parent 3cc90bb commit ed6b2a0
Showing 1 changed file with 40 additions and 45 deletions.
85 changes: 40 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,45 @@ db << "select age,name,img from tbl where id = 2"
};
```

SQLCipher
----

We have native support for [SQLCipher](https://www.zetetic.net/sqlcipher/).
If you want to use encrypted databases, include the `sqlite_moder_cpp/sqlcipher.h` header.
Then create a `sqlcipher_database` instead.

```c++
#include<iostream>
#include <sqlite_modern_cpp/sqlcipher.h>
using namespace sqlite;
using namespace std;

int main() {

try {
// creates a database file 'dbfile.db' if it does not exists with password 'secret'
sqlcipher_config config;
config.key = secret;
sqlcipher_database db("dbfile.db", config);

// executes the query and creates a 'user' table
db <<
"create table if not exists user ("
" _id integer primary key autoincrement not null,"
" age int,"
" name text,"
" weight real"
");";

// More queries ...
db.rekey("new_secret"); // Change the password of the already encrypted database.

// Even more queries ..
}
catch (exception& e) { cout << e.what() << endl; }
}
```

NULL values (DEPRICATED)
----
**Note: this option is deprecated and will be removed in future versions.**
Expand Down Expand Up @@ -324,53 +363,11 @@ To extend SQLite with custom functions, you just implement them in C++:
};
```
NDK support
----
Just Make sure you are using the full path of your database file :
`sqlite::database db("/data/data/com.your.package/dbfile.db")`.
SQLCipher
----
The library has native support for [SQLCipher](https://www.zetetic.net/sqlcipher/). If you want to use encrypted databases, you have to include the `sqlite_moder_cpp/sqlcipher.h` header.
Then you can create a `sqlcipher_database`.
```c++
#include<iostream>
#include <sqlite_modern_cpp/sqlcipher.h>
using namespace sqlite;
using namespace std;
int main() {
try {
// creates a database file 'dbfile.db' if it does not exists with password 'secret'
sqlcipher_config config;
config.key = secret;
sqlcipher_database db("dbfile.db", config);
// executes the query and creates a 'user' table
db <<
"create table if not exists user ("
" _id integer primary key autoincrement not null,"
" age int,"
" name text,"
" weight real"
");";
// More queries
db.rekey("new_secret"); // Change the password of the already encrypted database.
// Even more queries
}
catch (exception& e) {
cout << e.what() << endl;
}
}
```

Building and Installing
----
Expand All @@ -385,9 +382,7 @@ Note, there's nothing to make, so you there's no need to run configure and you c

Breaking Changes
----

- Databases with non-ASCII characters in their names created with versions up to 2.4 are not found by the current master.
You have to manually rename them to their actual (UTF-8 encoded) name.
See breaking changes documented in each [Release](https://github.com/aminroosta/sqlite_modern_cpp/releases).

Package managers
----
Expand Down

0 comments on commit ed6b2a0

Please sign in to comment.