https://github.com/raven-ie/NLDatabase
Lightweight C++ wrapper for SQLite
https://github.com/raven-ie/NLDatabase
Last synced: 17 days ago
JSON representation
Lightweight C++ wrapper for SQLite
- Host: GitHub
- URL: https://github.com/raven-ie/NLDatabase
- Owner: raven-ie
- License: mit
- Created: 2013-09-16T10:05:11.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-09-15T19:12:56.000Z (over 11 years ago)
- Last Synced: 2024-08-04T02:10:52.793Z (10 months ago)
- Size: 89.8 KB
- Stars: 0
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- AwesomeCppGameDev - NLDatabase
README
# NLDatabase
Lightweight C++ wrapper for SQLite.
## Requirements
- C++11 compiler
- SQLite 3## Usage
Let's open a database file and read some rows:
#include "NLDatabase.h"
using namespace std;
using namespace NL::DB;int main(int argc, const char * argv[]) {
Database db( "test.sqlite" );
auto results = db.query("SELECT * FROM test WHERE name <> ?", "TOM" );
for ( auto & row : results ) {
cout << "column[0]=" << row.column_string( 0 ) << endl;
}
}## Installation
It's a single header, just drop into your project, link sqlite3 and that's it.
## Demo
To run the simple demo, use the Xcode project or build it on the command line like this:
sqlite3 test.sqlite < test.sql
clang -o test -std=c++11 -lsqlite3 -lstdc++ main.cpp
./test## Known problems
- There is no error checking. None. Your queries must be perfect. Also, patches are welcome.
- If you look at the way the results are retrieved, you will realize that you can only iterate through them ONCE. I didn't see an obvious way to express this in code and make it impossible syntactically, so it's simply something you need to keep in mind.## See also
Goes well with [NLTemplate](https://github.com/catnapgames/NLTemplate) and possibly [Mongoose](https://github.com/cesanta/mongoose).