wcdb README

The project's README from github.com/Tencent/wcdb. As one markdown file: README.md.

WCDB

PRs Welcome Release Version LanguagePlatform

中文版本请参看这里

WCDB is an efficient, complete, easy-to-use mobile database framework used in the WeChat application. It's based on SQLite and SQLCipher, and supports five languages: C++, Java, Kotlin, Swift and Objective-C.

Feature

Easy-to-use

With ORM and WINQ, you can insert, update, query and delete objects from database in one line code:

// C++
database.insertObjects<Sample>(Sample(1, "text"), myTable);
database.updateRow("text2", WCDB_FIELD(Sample::content), myTable, WCDB_FIELD(Sample::id) == 1);
auto objects = database.getAllObjects<Sample>(myTable, WCDB_FIELD(Sample::id) > 0);
database.deleteObjects(myTable, WCDB_FIELD(Sample::id) == 1);
// Java
database.insertObject(new Sample(1, "text"), DBSample.allFields(), myTable);
database.updateValue("text2", DBSample.content, myTable, DBSample.id.eq(1));
List<Sample> objects = database.getAllObjects(DBSample.allFields(), myTable, DBSample.id.gt(0));
database.deleteObjects(myTable, DBSample.id.eq(1));
// Kotlin
database.insertObject<Sample>(Sample(1, "text"), DBSample.allFields(), myTable)
database.updateValue("text2", DBSample.content, myTable, DBSample.id.eq(1))
val objects = database.getAllObjects<Sample>(DBSample.allFields(), myTable, DBSample.id.gt(0))
database.deleteObjects(myTable, DBSample.id.eq(1))
// Swift
try database.insert(Sample(id:1, content:"text"), intoTable: myTable)
try database.update(table: myTable,
                    on: Sample.Properties.content,
                    with: "text2"
                    where:Sample.Properties.id == 1)
let objects: [Sample] = try database.getObjects(fromTable: myTable,
                                                where: Sample.Properties.id > 0)
try database.delete(fromTable: myTable where: Sample.Properties.id == 1)
// Objc
[database insertObject:sample intoTable:myTable];
[database updateTable:myTable
          setProperty:Sample.content
              toValue:@"text2"
                where:Sample.id == 1];
NSArray* objects = [database getObjectsOfClass:Sample.class
                                     fromTable:myTable
                                         where:Sample.id > 0];
[database deleteFromTable:myTable where:Sample.id == 1];

Efficient

Through the framework layer and sqlcipher source optimization, WCDB have more efficient performance.

Complete

WCDB summarizes common problems in practice to provide a more complete development experience for database development:

Compatibility

WCDB has interfaces in five languages: C++, Java, Kotlin, Swift, and Objc. Interfaces in different languages share the same underlying logic. The code structure of WCDB is shown in the figure below:

Under such architecture, WCDB in different languages can have the same interface structure and interface capabilities. In one project, you can write database code in different languages with one WCDB. Database logic in different languages will not conflict. Some global interfaces such as error monitoring can work on database logic in different languages at the same time.

Build and Install

Following wikies contain the detailed instructions about building and installing of WCDB.

Tutorials

Tutorials of different languages can be found below:

Contributing

If you are interested in contributing, check out the [CONTRIBUTING.md], also join our Tencent OpenSource Plan.

WCDB 正式加入TDS 腾讯端服务产品联盟,携手联盟其他成员,共同致力于构建开放共赢的大前端技术产品生态。

信息公示

wcdb (Tencent/wcdb)

Searching Database…

11.6K ·GitHub
What is this?WCDB is a cross-platform database framework built by WeChat on top of SQLite and SQLCipher, providing ORM, encryption, corruption recovery and other database features for mobile and desktop apps.
Is this a standalone app or a library I embed in my own project?It is a library/SDK you link into your own app; it exposes native interfaces in C++, Java, Kotlin, Swift and Objective-C with shared underlying logic.
How do I add WCDB to my project?Follow the language-specific wiki pages (C++, Java/Kotlin, Swift, or Objective-C) for the exact build and install steps for your platform.
What does WCDB build on under the hood?It is based on SQLite, uses SQLCipher for encryption, and uses Zstd for optional data compression.
Any catch before I start using it?The README itself has no inline install commands - you need to follow separate per-language wiki/tutorial pages to build and set it up, which adds a bit of setup overhead.
Who is WCDB meant for?It targets mobile app developers (iOS, Android) and desktop/cross-platform teams who need a production-grade embedded database with encryption and crash recovery, similar to what WeChat uses internally.
Which platforms does it run on?WCDB targets Android, iOS, macOS, Windows and Linux.
What is WINQ?WINQ (WCDB language integrated query) is a native query API that lets you write SQL-equivalent operations as in-language code instead of concatenating raw SQL strings.
What happens if my database file gets corrupted?WCDB includes a built-in repair kit specifically for recovering corrupted databases, so you don't need a separate recovery tool.
Can WCDB handle heavy concurrent access?Yes, it supports multi-threaded concurrent read-read and read-write access through a connection pool, and it's deeply optimized for mobile write-heavy scenarios like batch writes.
Does it support moving data between databases?Yes, WCDB has a Data Migration feature that moves data from one database to another via simple configuration, handling the intermediate state automatically.
Creator
Tencent
Size
83.8 MB
Stars
11.6K
Age
9y
Commits · 90 Days