Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

sqlite3pp

> 编程语言
Open source

SQLite3++ - C++ wrapper of SQLite3 API

641 stars0 likes1 views
WebsiteGitHub

About

SQLite3++ - C++ wrapper of SQLite3 API

PROJECT STATUS

Only the headeronly_src directory is currently maintained and updated. Other directories such as src, boost_src, and the top-level test directory are obsolete and kept only for historical reference.

sqlite3pp

This library makes SQLite3 API more friendly to C++ users. It supports almost all of SQLite3 features using C++ classes such as database, command, query, and transaction. The query class supports iterator concept for fetching records.

With ext::function class, it's also easy to use the sqlite3's functions and aggregations in C++.

Usage

database

cpp
// Open a database file or :memory:
sqlite3pp::database db("test.db");

// Simple execution
db.execute("INSERT INTO contacts (name, phone) VALUES ('Mike', '555-1234')");

// Move semantics
sqlite3pp::database db2 = std::move(db);

command

cpp
// Using stream-like binder (automatically uses sqlite3pp::copy)
sqlite3pp::command cmd(db, "INSERT INTO contacts (name, phone) VALUES (?, ?)");
cmd.binder() > id >> name >> phone;
  cout > sqlite3pp::ignore >> name >> phone;
  cout ("log_text", [](string s) {
  clog ("cpp_sum");

sqlite3pp::query qry(db, "SELECT cpp_sum(id) FROM contacts");

loadable extension

cpp
#define SQLITE3PP_LOADABLE_EXTENSION
#include 

extern "C" int sqlite3_extension_init(
  sqlite3 *pdb,
  char **pzErrMsg,
  const sqlite3_api_routines *pApi) {
  SQLITE_EXTENSION_INIT2(pApi);
  
  // Borrow the raw sqlite3 pointer
  sqlite3pp::database db(sqlite3pp::ext::borrow(pdb));
  
  // Register functions...
  return SQLITE_OK;
}

How to run tests

To run the comprehensive test suite:

bash
g++ -std=c++11 -Iheaderonly_src headeronly_src/test_all.cpp -lsqlite3 -o test_all && ./test_all

Important Note

Only the files in headeronly_src directory are maintained. All other source and test directories (src, boost_src, test) are deprecated and should not be used for new projects.

See also

  • http://www.sqlite.org/
  • https://github.com/iwongu/sqlite3pp/wiki

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C++

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言