Latest 0.0.9
Homepage https://github.com/alexiscn/SQLiteKit
License MIT
Platforms ios 10.0, requires ARC
Authors

Requirements

  • iOS 10.0+
  • Xcode 9.0+
  • Swift 4.0+

Installation

SQLiteKit is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SQLiteKit'

Example

1. Create your database file


func createDatabase() {
    let path = NSHomeDirectory().appending("db.sqlite")
    let db = SQLiteKit(path: path)
}

2. Define your table model


 class UserModel: SQLiteModelProtocol {
     let name: String
     let age: Int
     let avatarData: Data

     init(name: String, age: Int, avatar: Data) {
         self.name = name
         self.age = age
         self.avatarData = avatarData
     }

     // MARK: - SQLiteModelProtocol

     static var tableName: String {
         return "Users"
     }

     var values: [Any] {
         return [name, age, avatarData]
     }

     static var columns: [SQLiteColumn] {
         return [
             SQLiteColumn(name: "name", dataType: .string),
             SQLiteColumn(name: "age", dataType: .int),
             SQLiteColumn(name: "avatarData", dataType: .data)
         ]
     }
 }

3. Insert data

 func addUser(_ name: String, age: Int, avatarData: Data) {
     let user = User(name: name, age: age, avatarData: avatarData)
     // TODO
 }

Author

alexiscn

Latest podspec

{
    "name": "SQLiteKit",
    "version": "0.0.9",
    "license": {
        "type": "MIT"
    },
    "requires_arc": true,
    "source": {
        "git": "https://github.com/alexiscn/SQLiteKit.git",
        "tag": "0.0.9"
    },
    "summary": "SQLiteKit based on FMDB and Swift Codable",
    "homepage": "https://github.com/alexiscn/SQLiteKit",
    "authors": {
        "xushuifeng": "[email protected]"
    },
    "platforms": {
        "ios": "10.0"
    },
    "swift_version": "4.0",
    "source_files": "**/*.{swift}",
    "ios": {
        "dependencies": {
            "FMDB": []
        }
    }
}

Pin It on Pinterest

Share This