1-1条,共1条数据.
姓名评论创建日期操作
admin//: [Previous](@previous)

import Foundation
import GRDB // 添加依赖之后,本语句 似乎要 build之后才会生效,错误"no such file"才会消失
var str = "Hello, playground"

//: [Next](@next)

let path = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory, FileManager.SearchPathDomainMask.userDomainMask, true).first! as NSString

let dbname = path.appendingPathComponent("mydb.db")

let dbq = try! DatabaseQueue(path: dbname)

try! dbq.inDatabase { (db) -> Void in
print(db)
try? db.drop(table: "demo")
try? db.create(table: "demo", body: { (t) in
t.column("id", .integer).primaryKey()
t.column("name", .text)
t.column("created_at", .datetime)
t.column("age", .integer)

})

let df = DateFormatter()
df.dateFormat="yyyy-MM-dd HH:mm:s"
let todaytime = df.string(from: Date())
try db.execute("insert into demo(name,created_at,age) values(:name,:created_at,:age)", arguments: StatementArguments([
"name":"google...","created_at":todaytime,
"age":123
]))



for row in Row.fetch(db, "select * from demo order by id desc limit :limit",arguments:StatementArguments([
"limit":5
])){
print(row)
print(row.value(named: "age")! == 123)

}
}
2016-10-06删除