当前位置: 首页 > 软件库 > iOS代码库 > 其他(Others) >

SQLite.swift

授权协议 MIT
开发语言 Swift
所属分类 iOS代码库、 其他(Others)
软件类型 开源软件
地区 不详
投 递 者 伏业
操作系统 iOS
开源组织
适用人群 未知
 软件概览

SQLite.swift 是一个使用纯 Swift 语言封装 SQLite3 的操作框架。

特性:

  • 简单的查询和参数绑定接口

  • 安全、自动类型数据访问

  • 隐式提交和回滚接口

  • 开发者友好的错误处理和调试

  • 文档完善

  • 通过广泛测试

SQLite.playground Screen Shot

示例代码:

import SQLite

let db = Database("path/to/db.sqlite3")

db.execute(
    "CREATE TABLE users (" +
        "id INTEGER PRIMARY KEY, " +
        "email TEXT NOT NULL UNIQUE, " +
        "manager_id INTEGER, " +
        "FOREIGN KEY(manager_id) REFERENCES users(id)" +
    ")"
)

let stmt = db.prepare("INSERT INTO users (email) VALUES (?)")
for email in ["alice@example.com", "betsy@example.com"] {
    stmt.run(email)
}

db.totalChanges // 2
db.lastChanges  // {Some 1}
db.lastID       // {Some 2}

for row in db.prepare("SELECT id, email FROM users") {
    println(row)
    // [Optional(1), Optional("betsy@example.com")]
    // [Optional(2), Optional("alice@example.com")]
}

db.scalar("SELECT count(*) FROM users") // {Some 2}

let jr = db.prepare("INSERT INTO users (email, manager_id) VALUES (? ?)")
db.transaction(
    stmt.run("dolly@example.com"),
    jr.run("emery@example.com", db.lastID)
)
  • Swift 之 SQLite.swift的使用 GitHub地址 SQLite.swift SQLite.swift使用Swift 编写的一款SQLite工具,封装了各种sql操作,避免了纯sql语句的开发 安装 Carthage github "stephencelis/SQLite.swift" ~> 0.12.0 CocoaPods安装 pod 'SQLite.swift', '~> 0.

  • 在Objective-C中,用于数据持久化的方法有以下几种: 使用plist文件 使用preference 保存数据 NSKeyArchiver 归档 Sqlite3 CoreData 在日常开发中,虽然经常需要储存某些用户的个人信息之类的,这样我们用的更多的是plst和preference,但是对于大批量的数据,比如说TableView中的Data数据进行处理,还是需要数据库来进行处理。 Cor

  • 原理介绍就不说赘述了,直接集成。 1. cocoapods配置sdk pod 'SQLite.swift' 2. model模型直接用字段名得先封装以下,这里我们转换(宏定义)一下,方便引用 //1.声明model模型 class CDOptionModel: NSObject {     enum CDOptionType:String {         case yes = "YES"  

  • 转载自 https://www.jianshu.com/p/73e423921cdb https://github.com/stephencelis/SQLite.swift SQLite.swift的Github地址,现在有5千多个star,是swift语言中关于sqlite星数最多的框架,值得推荐。 SQLite.swift对SQLite进行了全面的封装,拥有全面的纯swift接口,即使你不会

  • ActiveSQLite 更简单的Swift数据库方案。项目地址:https://github.com/KevinZhouRafael/ActiveSQLite —————————————————————————————————— 在做swift数据库的时候,选择并不多,有三种:CoreData,SQLite,Realm。很多喜欢用SQL的开发者在Objective-c中使用FMDB,而在swif

  • 使用cocoapod 来进行引入 pod ‘SQLite.swift’ // // SQLiteTool.swift // CreateLectureForSwift // // Created by coder on 2019/6/25. // Copyright © 2019 AlexanderYeah. All rights reserved. // import Foundation im

  • 最近项目中使用到了sqlite.swift,其中的一些方法做一下记录,github上面有的就不做赘述了。 /** 根据字段和主键创建表 */ let primaryKey//主键 let keys//所以的列 do { try db?.run(users.create(ifNotExists: true, block:{ (t) in

  • SQLite.Swift : https://github.com/stephencelis/SQLite.swift   let filemgr = NSFileManager.defaultManager() let dirPaths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .User

  • 因为在IOS项目中用到了sqlite数据库,在github上寻找支持的库,找到了这个库 https://github.com/stephencelis/SQLite.swift 按照说明文件提示,下载下来这个工程,并将它附加到自己的工程中  然后再自己的工程里导入这个模块     import SQLite 简单的说下语法,首先要初始化这个库,例如我用的是一个外置的库,按照路径打开    let

相关阅读

相关文章

相关问答

相关文档