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
6
votes
1 answer

With GRDB, use raw sql BUT consume the results in the convenience form?

Here's an example SQL query which you can't build using the convenience builders in GRDB... let q = "job.id, job.name, job.city, ifnull(jobcategory.value, 'no category'), ifnull(jobpriority.value, 'no priority'), from job left join jobcategory…
Fattie
  • 27,874
  • 70
  • 431
  • 719
3
votes
0 answers

How do i determine if a user has given consent to show them personalised ads on iOS using admob?

Im currently implementing Admob into my iOS app. You can see the implementation under. While implementing a had a few question and after a lot of searching and documentation reading i still didn't have the answers. So here are my questions Should i…
swiftdev4585
  • 115
  • 1
3
votes
2 answers

Xcode 12 update breaks Pods and Products

I just updated Xcode to version 12. When I open up a previously working project I now get an error No such module 'GRDB'. I have tried deintegrating and reinstalling the Pods, cleaning the build folder, and restarting Xcode. Additionally, when I…
Bernard
  • 1,004
  • 1
  • 12
  • 21
3
votes
1 answer

Cannot find 'CodingKeys' in scope, inconsistent error

I'm working on a GRDB data model. My problem might be rooted by working on beta: Version 12.0 beta 2 (12A6163b). I've got an intermittent error showing up in several structs. Cannot find 'CodingKeys' shows up on a few lines in a few struct…
adamek
  • 2,324
  • 3
  • 24
  • 38
3
votes
1 answer

Swift GRDB Writing to Database Error "attempt to write a readonly database"

I am attempting to write to a database of quotes I have created. If the user selects the "favorite" button, it will add a 1 (or true) value into the favorite column on the SQLITE database. For some reason I cannot write to the database and when I…
Kevin Maldjian
  • 147
  • 1
  • 10
2
votes
1 answer

Trying to build my project but it always show error with my grbd_config.h

it show double-quoted include "grdb_config.h" in framework header, expected angle-bracketed instead but after I changed to angle bracketed,it says enter image description here , I have no idea what should I do right now. (and I try this…
Thoms Chen
  • 21
  • 2
2
votes
0 answers

Xcode iOS17 Simulator and GRDB - Class ... is implemented in both ... One of the two will be used. Which one is undefined

I have a Swift and SwiftUI app using GRDB and GRDBQuery that has been working well. (Thank you Gwendal Roué.) When I run the app using Xcode 15 beta and the iOS17 simulator, I get 42 new messages in the log when the app starts. The messages all…
Ian
  • 29
  • 4
2
votes
1 answer

Cannot use mutating member on immutable value when persisting to DB with GRDB

Whenever I try to persist an object to the DB using insert or upsert, Xcode complains Cannot use mutating member on immutable value. I understand why Xcode is complaining, but do I really have to make a copy of the function parameter just to save?…
Legion
  • 3,922
  • 8
  • 51
  • 95
2
votes
1 answer

How to create many-to-many association using GRDB in Swift?

I'm trying to setup an association between songs and albums. Each song can appear on one or more albums and each album can contain one or more songs. I decided to go with GRDB for my database solution but I'm stuck on this issue. What I tried: As…
Adam
  • 1,776
  • 1
  • 17
  • 28
2
votes
1 answer

SwiftUI FileDocument using Sqlite and GRDB

In a document-based SwiftUI application, I’d like to persist each document to a separate Sqlite file using GRDB as a Sqlite wrapper. It’s straightforward to load Sqlite files in a document that implements the FileDocument protocol by creating a…
Rich
  • 3,095
  • 17
  • 17
2
votes
1 answer

How to query a table with a 1-1 association on iOS using GRDB?

In my iOS project, I use GRDB to manage a SQLite database. I try to query a table with a 1-1 association. In my database, let's say I have 2 tables: Selections ---------- - selectionId (primary key) - position - idSong (foreign key) Songs ----- -…
matteoh
  • 2,810
  • 2
  • 29
  • 54
2
votes
1 answer

How can I create a Swift Combine publisher from two publishers A and B where publisher B consumes the value from publisher A?

I want to create a Swift Combine publisher which achieves the following: The publisher should be triggered by changes in either Defaults (a UserDefaults Swift package) or changes in GRDB sqlite database values (using GRDBCombine). The updated…
Simen
  • 417
  • 6
  • 13
2
votes
3 answers

how to get full QueryInterfaceRequest sql string in grdb including all arguments (GRDB.StatementArguments) in the string

I need to get full sql query of query interface in order to save them in user defaults but i couldn't find this functionality update: in order to achieve full query string: including arguments that were trimmed by sqlite for injection you can not…
Hamed Nova
  • 1,061
  • 9
  • 15
2
votes
2 answers

SQLite error 14 in ViewController

import GRDB class MyView: UIViewController{ override func viewDidLoad() { super.viewDidLoad() do{ let dbPool = try DatabasePool(path: "/path/to/database.sqlite") }catch let error{ print(error) } …
Adam
  • 325
  • 1
  • 4
  • 20
2
votes
1 answer

GRDB access to column values

I'm using GRDB in Swift 4 to access two columns ('col1', 'col2') of values of type Double. For example: let value = Double.fetchAll(db,"SELECT col1, col2 FROM table1") This should return a table with two columns of double values. I am wondering if…
J. Wadia
  • 37
  • 1
1
2 3 4