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

How to change column type with migration with GRDB Swift?

I have a couple of tables with UUID as the type of their columns. I want to convert those columns to String rather than UUID as debugging is just pain in the arse (e.g. browsing the sqlite file using DB Browser for SQLite requires me to do SQL query…
Glenn Posadas
  • 12,555
  • 6
  • 54
  • 95
0
votes
1 answer

How to use enum values as columns in a GRDB Record?

I want to make record of 4 different types. I have the following code import GRDB enum RecordType: Int16 { case video, image, text, rep } extension RecordType: DatabaseValueConvertible {} struct Record: Codable, FetchableRecord,…
BigBoy1337
  • 4,735
  • 16
  • 70
  • 138
0
votes
1 answer

What to do to make an existing non-optional field optional in database table in SQlite?

I am using GRDB for local persistence. Created a column in the Item table with the following constraints. table.column(Item.CodingKeys.text.rawValue, .text).notNull() Now I want to change it to support optional values as…
user8142828
0
votes
0 answers

SQLite slower than expected when querying

I have a fairly large (3,000,000 rows) SQLite database. It consist of one table. The table has an integer id column, a text-based tag column, a timestamp column saved as an int, and 15 double number columns. I have a unique index on the tag and…
Joseph
  • 9,171
  • 8
  • 41
  • 67
0
votes
1 answer

How to add items into an array that are in the struct but not in the Db table using GRDB

In the My_Quotes table (see MyQuotes struct below) in the Db I am storing the ID of the contact that was selected from the users Contacts on the device. This way if the contacts information is changed the ID remains constant. So I pull the ContactID…
Quailcreek
  • 125
  • 2
  • 9
0
votes
1 answer

How to set up an inner join with GRDB

The SQLite.Swift version works. With the GRDB version the app crashes and I get the following error. Thread 1: Fatal error: Database methods are not reentrant. What have I done wrong on the GRDB version. This is the SQLite.Swift version. static func…
Quailcreek
  • 125
  • 2
  • 9
0
votes
1 answer

Disabling or Deferring Foreign Key Enforcement with GRDB for Database Migration

I have taken the GRDB library into use in my mobile app. All current features are working nicely, and I have started implementing the migration from earlier databsase versions. For consistency with my implementation for other platforms, I have…
user3386180
0
votes
0 answers

GRDB framework is causing crashes in TestFlight: How do I correct this situaton?

I have a project that runs perfectly in Simulation, and on physical devices. It uses a Framework that I created that provides game logic. Originally this framework contained a framework that accesses sqlite, GRDB. This seemed to cause problems,…
Dan Donaldson
  • 1,061
  • 1
  • 8
  • 21
0
votes
1 answer

Converting app from SQLite.swift to GRDB.swift Second Question

I am continuing the conversion of a number of my apps from SQLite.sift to GRDB.swift. I converted my structs to add Codable, FetchableRecord so as to have them work better with GRDB. This was suggested in a reply to my first post on this…
Quailcreek
  • 125
  • 2
  • 9
0
votes
1 answer

Converting app from SQLite.swift to GRDB.swift

I'm trying to convert several of my apps to use GRDB.swift. Does anybody have or know where I can find a file to get me started? I've read over most of the GRDB docs but I'm not getting it. Below is a sample scenario. This I was able to convert from…
Quailcreek
  • 125
  • 2
  • 9
0
votes
1 answer

How do I determine whether a database connection is read/write or read-only in GRDB?

In GRDB I can create read-only database connections with try dbPool.read { db in I can create read-write database connections with try dbPool.write { db in In each case I can call a function from within the closure using db as an argument. In…
adamek
  • 2,324
  • 3
  • 24
  • 38
0
votes
0 answers

has no member 'save' in GRDB

I'm using GRDB and a custom struct. Fetching rows works perfectly, however the issue comes when trying to update or delete rows. When I try to add the line to save the record, I get a compiler error that the "variablename" has no member 'save'. …
PilotGuy
  • 41
  • 1
  • 6
0
votes
1 answer

DatabaseConnecton issue in GRDB swift

I would like to use SQLite database in my iOS app and there are different frameworks available. So my current focus is on GRDB and I have successfully created, inserted values, and received back with SQL commands as shown here. However, once the app…
Wajdan Ali
  • 179
  • 13
0
votes
1 answer

'sqlite3.h' file not found when using WhirlyGlobe and GRDB pods

I have a Podfile set up to use WhirlyGlobeMaply: platform :ios, '10.2' project 'MyProject.xcodeproj' target 'MyProject' do use frameworks! pod 'WhirlyGlobe', '2.4' pod 'WhirlyGlobeResources' [some other pods] end This builds fine. But…
vlz
  • 911
  • 1
  • 10
  • 18
0
votes
1 answer

compile error with rows.next() in GRDB and Swift 3

I am developing an iOS app using Swift 3 and the GRDB SQLite library. The following code fragment causes a compile error of "value of type '[Row]' has no member 'next'" let rows = try Row.fetchAll(db, sql, arguments:arguments) while let row = try…
Mc.Stever
  • 782
  • 6
  • 16