explaingit

ccgus/fmdb

13,847Objective-CAudience · developerComplexity · 2/5Setup · easy

TLDR

FMDB is an Objective-C library that wraps SQLite for iOS and macOS apps, letting you query and update local databases through a clean API instead of low-level C functions, with built-in thread-safe access via FMDatabaseQueue.

Mindmap

mindmap
  root((FMDB))
    Core API
      FMDatabase object
      SQL queries
      FMResultSet
    Thread safety
      FMDatabaseQueue
      Serialized writes
    Installation
      CocoaPods
      Carthage
      Swift Package Manager
    Optional features
      SQLCipher encryption
      Swift compatible
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

Store and query structured local data in an iOS or macOS app using SQLite without writing low-level C code.

USE CASE 2

Handle concurrent database access from multiple threads safely using FMDatabaseQueue to serialize reads and writes.

USE CASE 3

Add encrypted SQLite storage to a sensitive iOS app using the optional SQLCipher integration.

USE CASE 4

Replace raw SQLite C calls in an existing Objective-C or Swift project with a cleaner, more idiomatic API.

Tech stack

Objective-CSwiftSQLiteCocoaPodsCarthageSwift Package ManagerSQLCipher

Getting it running

Difficulty · easy Time to first run · 30min
No license information is mentioned in the explanation.

In plain English

FMDB is an Objective-C library for working with SQLite databases on Apple platforms, including iOS and macOS. SQLite is a local database built into Apple devices that stores structured data in a single file on the device. FMDB wraps SQLite in a more convenient Objective-C interface, making it easier to open, query, and update a database from within an iPhone or Mac app. Without a wrapper, calling SQLite from Objective-C requires working with low-level C functions and managing memory manually. FMDB handles that plumbing so you can write database operations in a style that fits naturally with the rest of your Apple codebase. You open a database with an FMDatabase object, run SQL queries or updates through straightforward method calls, and iterate over results with a simple result set object. The library includes FMDatabaseQueue, which handles the common scenario where multiple parts of an app try to read or write the database at the same time. SQLite does not allow concurrent writes from different threads, FMDatabaseQueue serializes those calls safely so they do not conflict. FMDB can be added to a project through CocoaPods, Carthage, or Swift Package Manager. It works with both Objective-C and Swift, and supports both the older manual memory management style and the modern automatic reference counting approach. The library also integrates optionally with SQLCipher, a separate project that adds transparent encryption to SQLite databases, which is useful if the app needs to store sensitive data securely on the device. The README notes this project is community-maintained. For full SQL reference, the project points developers to the SQLite documentation directly, since FMDB does not abstract away SQL itself. You still write SQL statements, FMDB just makes it easier to send them to the database and handle the results in Objective-C or Swift.

Copy-paste prompts

Prompt 1
Show me how to use FMDB in my iOS app to create a SQLite database, insert a row, and query it back using FMResultSet.
Prompt 2
My iOS app crashes when multiple threads write to the database at the same time. Show me how to use FMDatabaseQueue to serialize all database access.
Prompt 3
I need to store sensitive user data in my iPhone app. Guide me through adding FMDB with SQLCipher to encrypt the SQLite database on-device.
Prompt 4
How do I add FMDB to my iOS project using Swift Package Manager and call it from Swift with proper error handling?
Open on GitHub → Explain another repo

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

Verify against the repo before relying on details.