Engine SetupΒΆ

An instance of Amigo needs an engine to run the queries. Amigo comes with a SQLiteEngine out of the box. Let’s take a look at setting it up so we can create our schema:

import Amigo
import CoreData

// the first arg can be ":memory:" for an in-memory
// database, or it can be the absolute path to your
// sqlite database.
//
// echo : Boolean
// true prints out the SQL statements with params
// the default value of false does nothing.

let mom = NSManagedObjectModel(contentsOfURL: url)!

// specifying 'echo: true' will have amigo print out
// all of the SQL commands it's generating.
let engine = SQLiteEngineFactory(":memory:", echo: true)
amigo = Amigo(mom, factory: engine)
amigo.createAll()

Note, in the example above Amigo can process a ManagedObjectModel to create it’s schema. See models/mom for more.