Skip to content


Subversion checkout URL

You can clone with
Download ZIP
An Objective-C database abstraction framework.
Objective-C C
Branch: master
Failed to load latest commit information.
DatabaseKit.xcodeproj Made collection category private again, broke module header
Source Enforced relationship join row uniqueness
Tests Added error: to transaction:
en.lproj Made inflections compiled in, to get rid of the only external depende…
.gitattributes Gitignore&stuff
.gitignore ignored checkout file
Info.plist Renamed project to DatabaseKit
LICENSE Removed remaining references to old name Removed setClassPrefix: it's now automatically determined

DatabaseKit ReadMe


DatabaseKit is an unbelievably straight-forward to use database framework for Objective-C.


  • Supports SQLite, but is built to make it easy to add support for additional SQL databases, just subclass DBConnection.
  • Query composition done purely in Objective-C.
  • If you use a connection pool or queue(Done transparently by default) then query objects are thread safe.
  • If you provide a model class, then results from it's corresponding table will automatically be returned as instances of that class.
  • Supports creating and migrating tables for model classes at runtime.
  • Almost no code required.



// Open a SQLite database
DB *db = [DB withURL:[NSURL URLWithString:@"sqlite://myDb.sqlite"]];
    NSLog(@"Couldn't open database: %@.", [err localizedDescription]);


// Get the names of every person in our database
DBTable *people = db[@"people"];
DBSelectQuery *names = [people select:@"name"];

for(NSDictionary *row in [names limit:100]) {
    NSLog(@"Name: %@", row[@"name"]);

// Delete really old people
[[[people delete] where:@"bornOn < %@", [NSDate distantPast]] execute];

// Change the name of everyone called John
[[[people update:@{ @"name": @"Percie" }] where:@"name = %@", @"John"] execute];

// You can create a class to represent results from a table like so:
// (Our project's class prefix is `NICE`)
@interface NICEPerson : DBModel
@property(readwrite, retain) NSString *name, *address;
- (void)introduceYourself;

@implementation NICEPerson
- (void)introduceYourself
    NSLog(@"Hi! I'm %@.",;

// And now if you perform a query
NicePerson *someone = [[people select] firstObject];
[someone introduceYourself];
Something went wrong with that request. Please try again.