explaingit

tencent/wcdb

11,484CAudience · developerComplexity · 3/5Setup · moderate

TLDR

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.

Mindmap

mindmap
  root((wcdb))
    What it does
      Local database
      ORM wrapper
      Multi-platform
    Features
      Encryption
      Corruption recovery
      Full-text search
      Concurrent reads
    Tech Stack
      C++
      Swift
      Kotlin
      Objective-C
    Platforms
      iOS
      Android
      Windows
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add encrypted local storage to an iOS or Android app using WCDB's ORM so you write objects, not raw SQL

USE CASE 2

Recover user data from a corrupted on-device SQLite database without data loss using WCDB's repair tools

USE CASE 3

Implement full-text keyword search over locally stored content in a mobile app

USE CASE 4

Automatically migrate an existing database schema when your app ships a new version with new or changed columns

Tech stack

C++JavaKotlinSwiftObjective-CSQLite

Getting it running

Difficulty · moderate Time to first run · 30min

Integrate via CocoaPods on iOS/macOS, Gradle on Android, or CMake for C++ targets, each platform has its own setup path.

In plain English

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.

Copy-paste prompts

Prompt 1
Show me how to set up WCDB in a Swift iOS app to save and fetch user profile objects using ORM instead of writing raw SQL queries.
Prompt 2
My Android app's local SQLite database got corrupted on a user's device. Walk me through using WCDB's repair tools to recover the data.
Prompt 3
How do I enable database encryption in WCDB for an iOS app so that all stored data is protected at rest?
Prompt 4
I need full-text search over a list of notes stored in WCDB on Android. Show me how to create and query a full-text search index.
Prompt 5
Help me set up automatic schema migration in WCDB for iOS when I add a new column to an existing table in a new app release.
Open on GitHub → Explain another repo

← tencent on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.