Questions tagged [grdb]

GRDB is a popular Swift library used in relation to the SQLite database. Use this tag for questions about the use of GRDB. You would likely add the Swift tag, and possibly the SQL tag.

The GRDB library is at https://github.com/groue/GRDB.swift

It is a library for use in Swift projects which deal with the SQLite database.

It particularly focusses on performance and threading.

It deals with issues such as WAL support, migrations, reactive extensions, and change observation.

Links to GRDB installation, reference.

49 questions
1
vote
3 answers

Many-to-many relationship where one entity has multiple properties of the same type

I'm not sure how to phrase this, which may be why I couldn't find any information, but I have a many-to-many relationship where one of the entities has multiple properties of many of the other. For instance, take the Artist and Song relationship.…
AJP
  • 57
  • 4
1
vote
3 answers

How do I read data using GRDB in a SwiftUI application?

I am trying to follow this guide here: https://elliotekj.com/2019/12/11/sqlite-ios-getting-started-with-grdb and while helpful, it's not exactly a tutorial. So far I have this code: AppDatabase import GRDB var dbQueue: DatabaseQueue! class…
Rillieux
  • 587
  • 9
  • 23
1
vote
1 answer

SQLite CREATE TRIGGER ... SQLite error 1 with statement: incomplete input

trying to create a trigger in Xcode / Swift5 / GRDB. the trigger in the codeblock below fails silently, so I move it and see the error in the title [I have removed the text of the SQL statement from the title]. the weird part is that DB Browser will…
1
vote
0 answers

Using GRDBCombine to obtain unique items and display them in a list with SwiftUI

I have a sample test project at https://github.com/EricG-Personal/grdb_test.git In ContentView.swift, I currently have one list that shows all of the items in the Database. Below that, I would like another list that shows all of the unique 'names'…
ericg
  • 8,413
  • 9
  • 43
  • 77
1
vote
1 answer

How do I call a new database connection from within a read-only database connection in GRDB?

The function below returns a Ledgers record. Most of the time, it will find it in the optional _currentReceipt variable, or by searching the database, No writing needed there. I'd like to use a read-only GRDB database connection. Read-only database…
adamek
  • 2,324
  • 3
  • 24
  • 38
1
vote
2 answers

Adding minimal GRDB to an Xcode project using Swift Package Manager, Cocoa Pods, or other

The demo iOS application from GRDB on github runs great on the phone simulator of my iMac, but it's not clear how to get GRDB building in an iOS application of my own (part 1 of this question), with the minimal set of components (part 2 of this…
Dale
  • 5,520
  • 4
  • 43
  • 79
1
vote
1 answer

Running GRDB in a playground

Being new to this programming environment, this instruction that appears at the top of the playgrounds shipped with GRDB leaves me not knowing how to proceed: To run this playground, select and build the GRDBOSX scheme. Steps taken so far include…
Dale
  • 5,520
  • 4
  • 43
  • 79
1
vote
1 answer

GRDB.swift requests with swift 3 without going through models[Finish]

I can not make a simple select on a SQLite database, via GRDB.swift Here is my code: override func viewDidLoad() { super.viewDidLoad() do { let dbQueue = try DatabaseQueue(path: "games.sqlite") try…
user7475694
0
votes
0 answers

Swift GRDB Array of SQL Arguments interpolation not working

I'm using the latest version of GRDB and I'm trying to pass to a SQLRequest an array of arguments like this: class GamesDao { private var dbQueue: DatabaseQueue? init(dbQueue: DatabaseQueue) { self.dbQueue = dbQueue } func…
Nexussim Lements
  • 535
  • 1
  • 15
  • 47
0
votes
1 answer

How to enable FTS5 in GRDB.swift using SPM?

I'm using GRDB.swift package for communication with Database in App project. Package is added using Swift Package Manager. I would like to use FTS5, but as far as I see the FTS5 struct has condition #if SQLITE_ENABLE_FTS5. Is there a way to enable…
0
votes
2 answers

Updating multiple rows using instr

I am trying to make the following call: UPDATE MyTable SET path = ? WHERE instr(title, ?) AND start - ? < 60 However I have not been able to use instr with GRDB. _ = try dbQueue?.write { db in try MyTable .filter(Column("start") > date…
Silve2611
  • 2,198
  • 2
  • 34
  • 55
0
votes
0 answers

iOS Swift/GRDB - How to save metadata to table without needing column?

We have an array element in our json that we want to save off into its own table. However, we are struggling with saving off the data to the table without needing to add a column. Example of our json structure { fruits: [ { fruitID: "12345" …
mgrene
  • 1
0
votes
1 answer

How to change the dataType of a column from text to int with GRDB

I have my database pre-created and it gets loaded to the apps documents directory on the initial launch. I use DB Browser for SQLite In the database I have a table x with a column y. The column dataType is set to accept text and is currently empty.…
Quailcreek
  • 125
  • 2
  • 9
0
votes
2 answers

How do i make GRDB ignore a stored variable when fetching from SQLite?

I have a class that adopts both TableRecord and FetchableRecord. I am taging advantage of the automagic query generation provided by GRDB, and I only provide the table name because it doesn't match the class name. However now i want to add stored…
Maciej Swic
  • 11,139
  • 8
  • 52
  • 68
0
votes
1 answer

Compile errors with recent XCode Update

I recently update XCode to 13.2.1 but my project now has compilation errors in place where never exist before. This is related to the library GRDB.swift for local DB. I will appreciate any help. Thanks in advance.
Angel Ruiz
  • 31
  • 6