sqlite.swift

How to access an FTS table in SQLite.swift using the IN condition

ぐ巨炮叔叔 提交于 2020-01-13 18:07:27
问题 I'm trying to query an FTS table using SQLite.swift. Previously I have done it in Android. The essence of what I am trying to do is this: SELECT * FROM t2 WHERE id IN (SELECT docid FROM fts_table WHERE col_text MATCH 'something') From the SQLite.swift documentation I see the IN condition can be written like this: users.filter([1, 2, 3, 4, 5].contains(id)) // SELECT * FROM "users" WHERE ("id" IN (1, 2, 3, 4, 5)) And virtual tables can be queried like this: let wonderfulEmails = emails.match(

How to access an FTS table in SQLite.swift using the IN condition

我怕爱的太早我们不能终老 提交于 2020-01-13 18:06:45
问题 I'm trying to query an FTS table using SQLite.swift. Previously I have done it in Android. The essence of what I am trying to do is this: SELECT * FROM t2 WHERE id IN (SELECT docid FROM fts_table WHERE col_text MATCH 'something') From the SQLite.swift documentation I see the IN condition can be written like this: users.filter([1, 2, 3, 4, 5].contains(id)) // SELECT * FROM "users" WHERE ("id" IN (1, 2, 3, 4, 5)) And virtual tables can be queried like this: let wonderfulEmails = emails.match(

SQLite/SQLite-Bridging.h not found in SQLite.swift

断了今生、忘了曾经 提交于 2020-01-13 11:52:38
问题 I'm using SQLite.swit (https://github.com/stephencelis/SQLite.swift) to develop an app. I was following the Pod installation guide and can get it running on iOS simulator. However, when I try to install the app on my test device, it shows the error /Users/.../Build/Products/Debug-iphoneos/Pods/SQLite.framework/Headers/SQLite.h:9:9: error: 'SQLite/SQLite-Bridging.h' file not found Is it my way of configuration incorrect? Anyway ran into the same issue as mine? 回答1: I initially fixed this by

SQLite/SQLite-Bridging.h not found in SQLite.swift

五迷三道 提交于 2020-01-13 11:52:25
问题 I'm using SQLite.swit (https://github.com/stephencelis/SQLite.swift) to develop an app. I was following the Pod installation guide and can get it running on iOS simulator. However, when I try to install the app on my test device, it shows the error /Users/.../Build/Products/Debug-iphoneos/Pods/SQLite.framework/Headers/SQLite.h:9:9: error: 'SQLite/SQLite-Bridging.h' file not found Is it my way of configuration incorrect? Anyway ran into the same issue as mine? 回答1: I initially fixed this by

how to use filter to update row in SQLite.swift library?

℡╲_俬逩灬. 提交于 2019-12-24 20:26:45
问题 I am using SQLite.swift library. I have defined a expression: let id = Expression<Int64>("id") I have a variable: let num: Int = 1 Then, in update statement I do filtering: let users = Table("User") // compiler error: // Binary operator '==' cannot be applied to operands of type 'Expression<Int64>' and 'Int' users.filter(id == num) I get compiler error showing in above comment. I understand what the error is saying, but how to get rid of it? According to SQLite.swift library document, the

Using variables in Filters in SQLite.swift

不问归期 提交于 2019-12-23 20:58:21
问题 I am using SQLite.swift (Branch Swift-1-2) in my app in XCode 6.3 beta. I am able to create the Database/Tables and insert entries into the tables. So far so good. Now when I have a simple scenario as follows: class Foo { var id: Int? var name: String? /* constructor to create an instance ... */ } // This is how the table column is defined var id = Expression<Int64>("id") // Function to update data in the table func updateFoo(foo: Foo) -> Int? { // 'foos' is the table name let candidateFoo =

Add “blocking” to Swift for-loop

纵饮孤独 提交于 2019-12-23 04:24:59
问题 I am using Swift in a project, and using SQLite.swift for database handling. I am trying to retrieve the most recent entry from my database like below: func returnLatestEmailAddressFromEmailsTable() -> String{ let dbPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first as String let db = Database("\(dbPath)/db.sqlite3") let emails = db["emails"] let email = Expression<String>("email") let time = Expression<Int>("time") var returnEmail:String = "" for res

Adding an Xcode subproject: Shouldn't all the source files get copied?

守給你的承諾、 提交于 2019-12-22 07:07:17
问题 I am manually adding the SQLite.swift subproject to my project. As the directions indicated, I copied the .xcodeproj file to my project. This allows me see all the source files (unlike this SO question). Everything seemed like it was working fine. However, I discovered that the source files of that subproject were not copied to my project. They are still in original location where I downloaded them. Is this by design? What if I want to share my project source code with other people in the

How to create a Type-Safe custom function in SQLite.swift?

≯℡__Kan透↙ 提交于 2019-12-13 06:08:47
问题 I would like to create a simple distance function to order objects while fetched from a SQLite database in Swift2. I’m using the awesome SQLite.swift framework. With the following I could fetch the nearest objects: db.createFunction("distance") { (args) -> Binding? in assert(args.count == 4) if let lat1 = args[0] as? Double, let lon1 = args[1] as? Double, let lat2 = args[2] as? Double, let lon2 = args[3] as? Double { let deltaLat = lat1 - lat2 let deltaLon = lon1 - lon2 return deltaLat *

Getting results from arbitrary SQL statements with correct binding in SQLite.swift

大城市里の小女人 提交于 2019-12-12 07:22:46
问题 The SQLite.swift documentation says about executing arbitrary SQL: let stmt = try db.prepare("SELECT id, email FROM users") for row in stmt { for (index, name) in stmt.columnNames.enumerate() { print ("\(name)=\(row[index]!)") // id: Optional(1), email: Optional("alice@mac.com") } } I wanted to get the values directly like this let stmt = try db.prepare("SELECT id, email FROM users") for row in stmt { let myInt: Int64 = row[0] // error: Cannot convert value of type 'Binding?' to specified