wcdb
WCDB is a cross-platform database framework developed by WeChat.
A production-grade mobile database library from Tencent, used inside WeChat, that wraps SQLite with ORM, encryption, corruption recovery, and full-text search, supporting iOS, Android, macOS, Windows, Linux, and Harmony OS.
WCDB is a database library built by Tencent and used inside the WeChat messaging app. It gives mobile and desktop developers a way to store and retrieve structured data locally on a device, built on top of SQLite, which is the most widely used embedded database engine. WCDB runs on iOS, macOS, Android, Windows, Linux, and Harmony OS, and has interfaces for five programming languages: C++, Java, Kotlin, Swift, and Objective-C.
The library is designed to reduce the amount of code a developer has to write for common database tasks. Instead of writing raw SQL query strings by hand, developers can work with regular objects in their chosen language, and WCDB translates those operations into database reads and writes automatically. This approach, called ORM (Object Relational Mapping), means that saving a record or fetching a list of items can be done in a single line of code.
Beyond basic data storage, WCDB includes several built-in capabilities that address common problems in production apps. It supports encryption so the database contents can be protected at rest. It has tools to recover data from a corrupted database rather than losing it entirely. It protects against SQL injection, a class of security bug where malicious input can manipulate database queries. It also supports full-text search, which lets users search through content by keyword rather than exact match.
For performance, WCDB allows multiple threads to read data at the same time, and a read and a write can also run concurrently. The underlying SQLite engine has been tuned for mobile use, and batch write operations are specifically optimized for speed.
Additional features include automatic schema migration when a data model changes, data migration between databases, and optional field-level compression using the Zstd algorithm.
Where it fits
- Add encrypted local storage to an iOS or Android app using WCDB's ORM so you write objects, not raw SQL
- Recover user data from a corrupted on-device SQLite database without data loss using WCDB's repair tools
- Implement full-text keyword search over locally stored content in a mobile app
- Automatically migrate an existing database schema when your app ships a new version with new or changed columns