Questions tagged [sqlite.swift]

A third-party, type-safe, Swift-language layer over SQLite.

A third-party, type-safe, Swift-language layer over SQLite.

Related tags:

,

References:

252 questions
2
votes
1 answer

SQLite.swift: Can't retrieve table count due to unrecognized token: ":"

I'm trying to retrieve a count of records in a table using SQLite.swift and Swift in a Cocoa macOS application. According to the README, this can be achieved using the following: let users = Table("users") ... let count = try…
cognophile
  • 802
  • 11
  • 25
2
votes
1 answer

Accessing an Object (SQLite table) from another ViewController Swift 4

I am new to swift and what I am trying to do is return the specified columns in my table to display in a separate viewcontroller. I have defined a function using SQLite.swift which returns them in an array, just like I want them to be. (It works…
Adam7397
  • 57
  • 1
  • 7
2
votes
2 answers

When are records committed to disk with SQLite.swift?

I am struggling to see some INSERTs reflected in a SQLite database when using SQLite.swift. I debug my iOS app with breakpoints and after the insertion I export the app container (from device) to the host hard disk. Then I inspect the SQLite…
atineoSE
  • 3,597
  • 4
  • 27
  • 31
2
votes
1 answer

How do I make a column DEFAULT(NULL) in SQLite.swift

I'm trying to define my database structure, but I can't figure out how to set the default value of a column to NULL. This is what I want it to produce: CREATE TABLE test ( content text DEFAULT(NULL), ); I have the following code let content =…
oelna
  • 2,210
  • 3
  • 22
  • 40
2
votes
1 answer

iOS: Prevent file in the .cacheDirectory from being deleted on full storage warning

My Problem: I have my SQLite database file in the cache directory and set isExcludedFromBackup to true because i read, that doing so will prevent the iOS system from deleting it in case of full storage. But it gets deleted nonetheless. This was…
Remo
  • 33
  • 5
2
votes
1 answer

How can i close active connections in swift.sqlite to swap its sqlite.file

tl;dr: How do i close a read-/ write connection to a database in Sqlite.swift? Background story: I am using the sqlite.swift framework to manage a .sqlite file (data.sqlite) that is copied from the application bundle (bootstrap.sqlite) on app start…
MarkHim
  • 5,686
  • 5
  • 32
  • 64
2
votes
2 answers

SQLite.Swift how to get random row never repeating

I'm experimenting with SQlite.Swift in iOS and I'm trying to randomly pick a row from a table in an SQLite database. The table is movies and its columns are movieID, title genre and seen. Problem: Movies should be picked randomly but as soon as I…
Aeger
  • 138
  • 2
  • 11
2
votes
0 answers

How read data from sqlite with SQLite.swift?

I want to build a Dictionary app for iOS. I try to read data from sqlite database file with SQLite.swift here. My code func configureCell(){ //Todo: read sqlite file //let path = Bundle.main.path(forResource: "taidict", ofType: "sqlite")! …
SaiPha
  • 41
  • 6
2
votes
1 answer

Sqlite.Swift Ambiguous Column Name Swift

My code is as follows: let assetTag = Expression("asset_tag") let query2 = mdm.select(mdm[assetTag],os, mac, lastReported) .filter(mdm[assetTag] != "ipad" && location == facility) .order(mdm[assetTag]) …
Martheli
  • 931
  • 1
  • 16
  • 35
2
votes
3 answers

How to work with an existing SQLite database in iOS?

I recently started an iOS project and need to work with a standalone database that'll be downloaded from the internet when there are updates. This is my first iOS project, so am trying to get functionality working before designing the download…
The48Percent
  • 21
  • 1
  • 3
2
votes
1 answer

sqlite.swift get count values

I have the following code which retrieves list of operating systems and list of their counts. I would like to get the count values and save them to an array: let query = mdm.select(os,os.count) .filter(os != "") …
Martheli
  • 931
  • 1
  • 16
  • 35
2
votes
1 answer

Using transactions to insert is throwing errors Sqlite.swift

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("id") let cat_name =…
Richard Thompson
  • 404
  • 8
  • 23
2
votes
1 answer

Subtle cast warning when using SQLite.Swift ... Binding? to Any

Here's one, import SQLite var r:[[Any]] = [] do { if let stmt = try local.db?.prepare(q) { r = Array(stmt) } else { print("woe in sql?") } } catch { return [] } the call r…
Fattie
  • 27,874
  • 70
  • 431
  • 719
2
votes
1 answer

Sqlite.swift no such table error

I have created a function for mapping json data to a sqlite store using sqlite.swift. I am receiving strange behavior though since the first time I try to run an insert I get a "No such table" error". But the inserts work perfectly after that…
Sean Cook
  • 435
  • 7
  • 21
2
votes
0 answers

Sqlite.Swift: how to filter for null columns?

In my previous question: How to create a filter that does the SQL equivalent of WHERE ... IN for SQLite.Swift I asked how to how to do a WHERE...IN in swift. Now, how do I filter optional Expressions? I have a versioned database that allows me to…
stephw
  • 513
  • 1
  • 4
  • 19