Created: 2008-04-10 21:14
Updated: 2019-01-22 06:42
License: other

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];
Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more