{"repo":"yhirose/cpp-sqlitelib","free":true,"listed":false,"github":"https://github.com/yhirose/cpp-sqlitelib","clone":"git clone https://github.com/yhirose/cpp-sqlitelib.git","description":"C++ SQLite wrapper library","language":"C","stars":65,"topics":["cpp","head-only","sqlite"],"license":"MIT","category":"databases-storage","readme_excerpt":"cpp-sqlitelib ============= A single file C++ header-only SQLite wrapper library Open database #include using namespace sqlitelib; auto db = Sqlite(\"./test.db\"); Create table db.execute(R\"( CREATE TABLE IF NOT EXISTS people ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, data BLOB ) )\"); Drop table db.execute(\"DROP TABLE IF EXISTS people\"); Insert records auto stmt = db.prepare(\"INSERT INTO people (name, age, data) VALUES (?, ?, ?)\"); stmt.execute(\"john\", 10, vector ({ 'A', 'B', 'C', 'D' })); stmt.execute(\"paul\", 20, vector ({ 'E', 'B', 'G', 'H' })); stmt.execute(\"mark\", 15, vector ({ 'I', 'J', 'K', 'L' })); stmt.execute(\"luke\", 25, vector ({ 'M', 'N', 'O', 'P' })); Select a record (single colum) auto val = db.execute value (\"SELECT age FROM people WHERE name='john'\"); val; // 10 Select records (multiple columns) auto rows = db.execute (\"SELECT age, name FROM people\"); rows.size(); // 4 auto [age, name] = rows[3]; // age: 25, name: luke Bind #1 auto stmt = db.prepare (\"SELECT name FROM people WHERE age ?\"); auto rows = stmt.execute(10); rows.size(); // 3 rows[0]; // paul auto rows = stmt.bind(10).execute(); rows.size(); // 3 rows[0]; // paul Bind #2 auto val = db.execute value (\"SELECT id FROM people WHERE name=? AND age=?\", \"john\", 10); val; // 1 Cursor (multiple columns) auto stmt = db.prepare (\"SELECT name, age FROM people\"); auto cursor = stmt.execute cursor(); for (auto it = cursor.begin(); it != cursor.end(); ++it) { get ( it); get ( it); ++it; } // With","default_branch":null,"files":null,"tree":[],"storefront":"/r/yhirose","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/yhirose/cpp-sqlitelib/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}