Swift ORM framework.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Version Author Build Passing Swift
Platforms MIT
Cocoapods Carthage SPM

🏵 Introduction

Sqlable is a tiny library for ORM written in Swift.

📋 Requirements

  • iOS 8.0+
  • macOS 10.10+
  • tvOS 9.1+
  • watchOS 2.2+
  • Xcode 9.0+ with Swift 4.0+

📲 Installation

Sqlable is available on CocoaPods:

pod 'Sqlable'

❤️ Contribution

You are welcome to fork and submit pull requests.

🔖 License

Sqlable is open-sourced software, licensed under the MIT license.

💫 Usage

First, create a model:

struct User {
  var name: String

then, extend the model to confirm Sqlable protocol:

extension User: Sqlable {


and, we need to create the database columns:

extension User: Sqlable {
    // create your columns:

    static let id = SQLColumn("id", .integer, PrimaryKey(autoincrement: true))
    static let name = SQLColumn("name", .text)
    static var tableLayout: [SQLColumn] = [id, name]

    // implement there two functions:

    func valueForColumn(_ column: SQLColumn) -> SQLValue? {
        switch column {
        case User.name:
            return self.name
            return nil

    init(row: SQLReadRow) throws {
        name = try row.get(User.name)

now, get your database:

let doc = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
let database = try SQLiteDatabase.init(filepath: doc.appendingPathComponent("User.db").path)

create table if not exists:

try database.create(table: User.self)

do your work, let's insert for example:

try user.insert(into: database)


try User.query(in: database)