百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
W

wcdb

> 数据库
开源

WCDB是一个由WeChat开发的跨平台数据库框架.

11.6K stars0 点赞2 次浏览
访问官网GitHub

工具介绍

WCDB是一个由WeChat开发的跨平台数据库框架.

WCDB

中文版本请参看这里

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

  • ORM (Object Relational Mapping): WCDB provides a flexible, easy-to-use ORM for creating tables, indices and constraints, as well as CRUD through C++/Java/Kotlin/Swift/Objc objects.
  • WINQ (WCDB language integrated query): WINQ is a native data querying capability which frees developers from writing glue code to concatenate SQL query strings.

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

cpp
// 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
// 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
// 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
// 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)
objective-c
// 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.

  • Multi-threaded concurrency: WCDB supports concurrent read-read and read-write access via connection pooling.
  • Deeply optimized: WCDB has deeply optimized the source code and configuration of SQLite to adapt to the development scenarios of mobile terminals. At the same time, WCDB has also been optimized for common time-consuming scenarios, such as writing data in batches.

Complete

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

  • Encryption Support: WCDB supports database encryption via SQLCipher.
  • Corruption recovery: WCDB provides a built-in repair kit for database corruption recovery.
  • Anti-injection: WCDB provides a built-in protection from SQL injection.
  • Database model upgrade: The database model is bound to the class definition, so that the addition, deletion and modification of database fields are consistent with the definition of class variables.
  • Full-text search: WCDB provides an easy-to-use full-text search interface and includes tokenizers for multiple languages.
  • Data Migration: WCDB supports to migrate data from one databasse to another with simple configuration. And developers don't need to care about the intermediate status and progress of the migration.
  • Data Compression: WCDB supports to compress content via Zstd within specific fields of a database table through a simple configuration. Once configured, the details of data compression and decompression become transparent to developers, and WCDB can automatically compress existing data.

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.

  • Building and Installing of WCDB C++
  • Building and Installing of WCDB Java/Kotlin
  • Building and Installing of WCDB Swift
  • Building and Installing of WCDB Objc

Tutorials

Tutorials of different languages can be found below:

  • Tutorials for WCDB C++
  • Tutorials for WCDB Java/Kotlin
  • Tutorials for WCDB Swift
  • Tutorials for WCDB Objc

Contributing

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

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

信息公示

  • 开发者: 深圳市腾讯计算机系统有限公司

  • WCDB 个人信息保护规则

Issues· 26 开放

查看全部 Issues在 GitHub 打开
  • #1556

    是否仍然存在SQLCipher 的两个漏洞

    更新于 2026年9月22日
  • #1555

    在任何已有的 WAL 数据库上执行 VACUUM INTO 时,会出现 SQLITE_IOERR_LOCK/EBADF 错误: 真空目标继承了 SQLITE_OPEN_MAINDB_READONLY

    更新于 2026年8月14日
  • #1554

    [压缩] wcdb_decompress rewrite 会跳过 joinClause; JOIN 查询返回压缩的 BLOB

    更新于 2026年8月6日
  • #1553

    备份问题

    更新于 2026年8月4日
  • #1552

    Android 构建链接预构建的 OpenSSL 1.0.2k (2017 年 1 月) 到 sqlcipher,而同一个仓库中的 1.1.1l 树未被引用

    更新于 2026年7月29日
  • #1551

    Android 没有找到与 2.1.16 对应的产品

    更新于 2026年7月24日
  • #1545

    Swift 数据迁移存在BUG

    更新于 2026年7月1日
  • #1549

    [Android][KSP] 生成的 Kotlin ORM 无法编译自动递增的长整型主键(运算符 '==' 不能应用于 'Long' 和 'Int')

    更新于 2026年6月8日
  • #1548

    Android 原生崩溃

    更新于 2026年6月2日
  • #1543

    从1.x版本升级到2.x后,如何获取columName?

    更新于 2026年4月9日

> 标签

Candroiddatabaseioslinux

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月28日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库