sqlite.swift

How to create a filter that does the SQL equivalent of WHERE … IN for SQLite.Swift

∥☆過路亽.° 提交于 2019-12-12 03:28:16
问题 I would like to filter results for the same column with multiple values example in sql: SELECT * FROM myTable WHERE status = 1 AND current_condition = ("New", "Working") this will return all rows from myTable where the status is 1 and the current_condition is "New" OR "Working" how do I do this in SQLite.swift? 回答1: You can use raw SQL in Swift. So you can use the string you posted. Raw SQL Using Filters I use Filters, gives me more insight. 来源: https://stackoverflow.com/questions/36126350

sqlite.swift linked library or also embedded?

淺唱寂寞╮ 提交于 2019-12-11 11:12:36
问题 I manually installed the SQLite.swift library in my project, following the instructions in the documentation. But there the library will only be linked. It's running fine in the emulator and I am able to upload it to iTunes connect. When I want to run it directly on my iPad from Xcode I need to embed the library, too. My question is, if for publishing the app in iTunes connect and so to be able to run it on a device do I have to embed the library, too? It seems strange to me, because in the

Cannot import SQLite for SQLite Swift wrapper

别来无恙 提交于 2019-12-11 04:32:36
问题 I followed the SQLite.Swift manual installation process exactly (https://github.com/stephencelis/SQLite.swift), but a red warning appears at "import SQLite". OSX (10.11.6) XCode 7.3.1 Question Do I need to create and include a header file? Reference info In SQLite.xcodeproj, libsqlite3.tbd is automatically linked instead of libsqlite3.dyslib. 回答1: After following the SQLite.Swift manual installation process, Select SQLite iOS from Product -> Scheme. Now select Build from Product menu. After

iOS SQLite.swift, regarding upgrade of app?

可紊 提交于 2019-12-10 02:56:35
问题 Regarding the magnificent and amazing SQLite.swift, I'm wondering You have an app in the app store, v7. There's an upgrade to v8. User X does upgrade v7 to v8 using the app store. Say in v8, we have slightly changed one of the sql tables, perhaps add a column or rename a column. Should anything or must anything special be done in SQLite.swift in this case? What's the SQLite.swift way to handle that? (In for example, Android there's a handy onUpgrade concept in their helper class ... which

What different between store database in different locations in iOS?

会有一股神秘感。 提交于 2019-12-09 01:04:05
问题 I'm working with SQLite.swift. In the document, the path to the database is: let path = NSSearchPathForDirectoriesInDomains( .DocumentDirectory, .UserDomainMask, true ).first! but i want to import and use an existing database, so i've dragged my existing database to my keyboard extension folder, and create connection to it with path is: let path = NSBundle.mainBundle().pathForResource("db", ofType:"sqlite3") So, i've noticed that the first way, the database will be store in /Users/*/Library

How to insert into Sqlite with optional parameters using Swift 3

别来无恙 提交于 2019-12-08 06:38:40
问题 I have this class with some optional properties: class Address { var Id: Int64 var AddressType: Int64 var AddressStatus: Int64 var Address1: String? var Address2: String? var City: String? var State: String? var Zip: String? var Country: String? var Latitude: Double? var Longitude: Double? } I am trying to insert into a Sqlite database, like this: let insert = table.insert(or: .replace, Id <- item.Id, AddressType <- item.AddressType, AddressStatus <- item.AddressStatus, Address1 <- item

Problem with SQLite.swift after migration to Swift 5

☆樱花仙子☆ 提交于 2019-12-08 05:03:01
问题 I use SQLite.swift and after upgrading to Swift 5 an error appears in the library. Please help me rewrite the method. Error: 'withUnsafeBytes' is deprecated: use `withUnsafeBytes<R>(_: (UnsafeRawBufferPointer) throws -> R) rethrows -> R` instead Code: public var datatypeValue: Blob { return withUnsafeBytes { (pointer: UnsafePointer<UInt8>) -> Blob in return Blob(bytes: pointer, length: count) } } 回答1: Till SQLite.swift doesn't release any update with the fix you could try modify manually the

iOS: How to copy pre-seeded database at the first running app with SQLite.swift to writeable location?

懵懂的女人 提交于 2019-12-08 04:13:59
问题 I had the previous question here about database location. What different between store database in different locations in iOS? I'm confused in copying pre-seeded database to the writable location. Now, every time I run and build my app, the in-use database will be replaced by pre-seeded db. And in the future, if I update my app version, how do I prevent the database from being replaced? 回答1: how do I prevent the database from being replaced? Check the destination before you copy the database.

Using transactions to insert is throwing errors Sqlite.swift

雨燕双飞 提交于 2019-12-08 02:15:00
问题 I have created a Database class as so: class Database { static let instance = Database() private let categories = Table("Category") private var db: Connection? let cat_id = Expression<String>("id") let cat_name = Expression<String>("name") private init() { let path = NSSearchPathForDirectoriesInDomains( .documentDirectory, .userDomainMask, true ).first! do { db = try Connection("\(path)/SalesPresenterDatabase.sqlite3") createTable() } catch { print("error") } } func createTable() { do{ try

Sqlite.swift create dynamic complex queries

爱⌒轻易说出口 提交于 2019-12-07 22:07:15
问题 I have 1 table with multiple columns. On the app, we are looking forward to add 4 dynamic filters like (cat, size, color,shape). We know we can create a filter to sqllite like so: user = user.select(name) .filter((color == "Blue") && (size = "Big") && (cat="a") && (shape="round")) .order(name.asc, name) // ORDER BY "email" DESC, "name" .limit(5, offset: 0) But what happens if a filter, let's say that for color we want to search for all colors. Then, .filter((color == "?????") && (size = "Big"