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
这是什么?WCDB 是微信基于 SQLite 和 SQLCipher 开发的跨平台数据库框架,为移动端和桌面端应用提供 ORM、加密、损坏修复等数据库功能。
这是独立应用,还是我可以嵌入自己项目里的库?它是一个库/SDK,你可以把它链接到自己的应用中;它提供 C++、Java、Kotlin、Swift 和 Objective-C 的原生接口,底层逻辑是共享的。
我该怎么把 WCDB 加入我的项目?请参考对应语言的 Wiki 页面(C++、Java/Kotlin、Swift 或 Objective-C),按照你所用平台的具体构建和安装步骤操作。
WCDB 底层是基于什么构建的?它基于 SQLite 构建,使用 SQLCipher 实现加密,并使用 Zstd 进行可选的数据压缩。
开始使用之前有什么需要注意的吗?README 本身没有内嵌的安装命令,你需要查阅各语言单独的 Wiki/教程页面来完成构建和配置,这会带来一些额外的设置工作。
WCDB 适合哪些人使用?它面向移动应用开发者(iOS、Android),以及需要带加密和崩溃恢复功能的生产级嵌入式数据库的桌面端和跨平台团队,其能力与微信内部使用的方案相近。
它能在哪些平台上运行?WCDB 支持 Android、iOS、macOS、Windows 和 Linux。
什么是 WINQ?WINQ(WCDB 语言集成查询)是一套原生查询 API,让你可以用编程语言本身的代码编写等价于 SQL 的操作,而不必拼接原始 SQL 字符串。
如果我的数据库文件损坏了怎么办?WCDB 内置了专门用于修复损坏数据库的修复工具包,因此你无需单独使用其他恢复工具。
WCDB 能应对高并发访问吗?可以,它通过连接池支持多线程并发的读-读和读-写访问,并针对移动端批量写入等写密集场景进行了深度优化。
它支持在数据库之间迁移数据吗?支持,WCDB 提供数据迁移功能,只需简单配置即可将数据从一个数据库迁移到另一个,中间状态由系统自动处理。
Creator
Tencent
Size
83.8 MB
Stars
11.6K
Age
9y
Commits · 90 Days