You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Path to the database, should be set before opening the database with `open_db()`. If no database with this name exists, a new one at the supplied path will be created. Both `res://` and `user://` keywords can be used to define the path.
Contains the zErrMsg returned by the SQLite query in human-readable form. An empty string corresponds with the case in which the query executed succesfully.
60
+
#### ~ Properties ~
59
61
60
-
-**default_extension** (String, default="db")
62
+
-**path** (String, default="database.db")
61
63
62
-
Default extension that is automatically appended to the `path`-variable whenever **no** extension is detected/given.
64
+
Path to the database. This is a read-only property that cannot be modified after opening the connection.
63
65
64
-
***NOTE**: If database files without extension are desired, this variable has to be set to "" (= an empty string) as to skip this automatic procedure entirely.*
66
+
-**error_message** (String, default="")
67
+
68
+
Contains the zErrMsg returned by the SQLite query in human-readable form. An empty string corresponds with the case in which the query executed succesfully.
65
69
66
70
-**foreign_keys** (Boolean, default=false)
67
71
68
72
Enables or disables the availability of [foreign keys](https://www.sqlite.org/foreignkeys.html) in the SQLite database.
69
73
70
74
-**read_only** (Boolean, default=false)
71
75
72
-
Enabling this property opens the database in read-only modus & allows databases to be packaged inside of the PCK. To make this possible, a custom [VFS](https://www.sqlite.org/vfs.html) is employed which internally takes care of all the file handling using the Godot API.
73
-
74
-
-**query_result** (Array, default=[])
75
-
76
-
Contains the results from the latest query **by value**; meaning that this property is safe to use when looping successive queries as it does not get overwritten by any future queries.
Binds the parameters contained in the `param_bindings`-variable to the query. Using this function stops any possible attempts at SQL data injection as the parameters are sanitized. More information regarding parameter bindings can be found [here](https://www.sqlite.org/c3ref/bind_blob.html).
117
103
@@ -189,23 +175,23 @@ Additionally, a video tutorial by [Mitch McCollum (finepointcgi)](https://github
Each key/value pair of the `row_dictionary`-variable defines the column values of a single row.
195
181
196
182
Columns should adhere to the table schema as instantiated using the `table_dictionary`-variable and are required if their corresponding **"not_null"**-column value is set to `True`.
Connection parameters that have to be passed to `SQLiteConnection.open()`.
271
+
272
+
#### ~ Properties ~
273
+
274
+
- **path** (String, default="database.db")
275
+
276
+
Path to the database. A new database is automatically created if there is no existing database at the supplied path. Both `res://` and `user://` keywords can be used to define the path.
277
+
278
+
- **read_only** (Boolean, default=false)
279
+
280
+
Enabling this property opens the database in read-only modus & allows databases to be packaged inside of the PCK. To make this possible, a custom [VFS](https://www.sqlite.org/vfs.html) is employed which internally takes care of all the file handling using the Godot API.
The verbosity_level determines the amount of logging to the Godot console that is handy for debugging your (possibly faulty) SQLite queries.
285
+
286
+
***NOTE**: VERBOSE and higher levels might considerably slow down your queries due to excessive logging.*
287
+
288
+
### 🔢 <a name="sqlite-enums">SQLiteEnums</a>
289
+
290
+
Common enums used by the Godot SQLite plugin.
291
+
292
+
Result codes starting with "RC_SQLITE_" come directly from SQLite. Detailed descriptions for those result codes are available [here](https://sqlite.org/rescode.html).
293
+
294
+
#### ~ Enumerations ~
295
+
296
+
- **ResultCode**
297
+
298
+
- **RC_SQLITE_OK** = 0
299
+
- **RC_SQLITE_ERROR** = 1
300
+
- **RC_SQLITE_INTERNAL** = 2
301
+
- **RC_SQLITE_PERM** = 3
302
+
- **RC_SQLITE_ABORT** = 4
303
+
- **RC_SQLITE_BUSY** = 5
304
+
- **RC_SQLITE_LOCKED** = 6
305
+
- **RC_SQLITE_NOMEM** = 7
306
+
- **RC_SQLITE_READONLY** = 8
307
+
- **RC_SQLITE_INTERRUPT** = 9
308
+
- **RC_SQLITE_IOERR** = 10
309
+
- **RC_SQLITE_CORRUPT** = 11
310
+
- **RC_SQLITE_NOTFOUND** = 12
311
+
- **RC_SQLITE_FULL** = 13
312
+
- **RC_SQLITE_CANTOPEN** = 14
313
+
- **RC_SQLITE_PROTOCOL** = 15
314
+
- **RC_SQLITE_EMPTY** = 16
315
+
- **RC_SQLITE_SCHEMA** = 17
316
+
- **RC_SQLITE_TOOBIG** = 18
317
+
- **RC_SQLITE_CONSTRAINT** = 19
318
+
- **RC_SQLITE_MISMATCH** = 20
319
+
- **RC_SQLITE_MISUSE** = 21
320
+
- **RC_SQLITE_NOLFS** = 22
321
+
- **RC_SQLITE_AUTH** = 23
322
+
- **RC_SQLITE_FORMAT** = 24
323
+
- **RC_SQLITE_RANGE** = 25
324
+
- **RC_SQLITE_NOTADB** = 26
325
+
- **RC_SQLITE_NOTICE** = 27
326
+
- **RC_SQLITE_WARNING** = 28
327
+
- **RC_SQLITE_ROW** = 100
328
+
- **RC_SQLITE_DONE** = 101
329
+
- **RC_GDSQLITE_ERROR** = 10000
330
+
Error that does not correspond to any of the result codes defined by SQLite.
331
+
332
+
- **VerbosityLevel**
333
+
334
+
- **QUIET** = 0
335
+
Don't print anything to the console.
336
+
- **NORMAL** = 1
337
+
Print essential information to the console.
338
+
- **VERBOSE** = 2
339
+
Print additional information to the console.
340
+
- **VERY_VERBOSE** = 3
341
+
Same as **VERBOSE**.
342
+
282
343
## Frequently Asked Questions (FAQ)
283
344
284
345
### 1. My query fails and returns syntax errors, what should I do?
Open a new database connection. Multiple concurrently open connections to the same database are possible.
54
-
</description>
55
-
</method>
56
-
<methodname="close_db">
54
+
<methodname="open">
57
55
<returntype="ResultCode" />
58
56
<description>
59
-
Close the current database connection.
57
+
Creates a new [bold]SQLiteConnection[/bold] object. Multiple concurrently open connections to the same database are possible.
58
+
Returns null if opening the connection failed. You can use [method get_open_error] to check the error that occurred.
60
59
</description>
61
60
</method>
62
61
<methodname="query">
@@ -122,7 +121,7 @@
122
121
<methodname="insert_row">
123
122
<returntype="ResultCode" />
124
123
<description>
125
-
Each key/value pair of the [code]row_dictionary[/code]-variable defines the column values of a single row.
124
+
Each key/value pair of the [code]row_data[/code]-variable defines the column values of a single row.
126
125
Columns should adhere to the table schema as instantiated using the [code]table_dictionary[/code]-variable and are required if their corresponding [b]"not_null"[/b]-column value is set to [code]True[/code].
127
126
</description>
128
127
</method>
@@ -135,7 +134,7 @@
135
134
<methodname="select_rows">
136
135
<returntype="Array" />
137
136
<description>
138
-
Returns the results from the latest query [b]by value[/b]; meaning that this property does not get overwritten by any successive queries.
137
+
Select specific rows from a table given the conditions defined in the conditions argument. The [code]columns[/code] input argument should be an array of strings where each string is a valid column name.
139
138
</description>
140
139
</method>
141
140
<methodname="update_rows">
@@ -166,14 +165,14 @@
166
165
<returntype="ResultCode" />
167
166
<description>
168
167
Drops all database tables and imports the database structure and content encoded in JSON-formatted input buffer.
169
-
Can be used together with [method SQLite.export_to_buffer] to implement database encryption.
168
+
Can be used together with [method export_to_buffer] to implement database encryption.
170
169
</description>
171
170
</method>
172
171
<methodname="export_to_buffer">
173
172
<returntype="PackedByteArray" />
174
173
<description>
175
174
Returns the database structure and content as JSON-formatted buffer.
176
-
Can be used together with [method SQLite.import_from_buffer] to implement database encryption.
175
+
Can be used together with [method import_from_buffer] to implement database encryption.
177
176
</description>
178
177
</method>
179
178
<methodname="create_function">
@@ -188,6 +187,12 @@
188
187
Check if the given database connection is or is not in autocommit mode, see [url=https://sqlite.org/c3ref/get_autocommit.html]here[/url].
189
188
</description>
190
189
</method>
190
+
<methodname="get_open_error">
191
+
<returntype="ResultCode" />
192
+
<description>
193
+
Returns the result of the last [method open] call in the current thread.
194
+
</description>
195
+
</method>
191
196
<methodname="backup_to">
192
197
<returntype="ResultCode" />
193
198
<description>
@@ -232,7 +237,7 @@
232
237
<methodname="load_extension">
233
238
<returntype="int" />
234
239
<description>
235
-
Loads the extension in the given path. Does not require [method SQLite.enable_load_extension], as it only enables C-API during the call and disables it right after, utilizing the recommended extension loading method declared by the SQLite documentation ([url=https://www.sqlite.org/c3ref/load_extension.html]see[/url]). Returns the SQLite return code.
240
+
Loads the extension in the given path. Does not require [method enable_load_extension], as it only enables C-API during the call and disables it right after, utilizing the recommended extension loading method declared by the SQLite documentation ([url=https://www.sqlite.org/c3ref/load_extension.html]see[/url]). Returns the SQLite return code.
236
241
- [b]extension_path:[/b] the path to the compiled binary of the extension
237
242
- [b]entrypoint:[/b] the extension's entrypoint method (init function). It is defined in the .c file of the extension.
238
243
Example for loading the spellfix module:
@@ -244,14 +249,17 @@
244
249
</methods>
245
250
<members>
246
251
<membername="path"type="String"default="default">
247
-
Path to the database, should be set before opening the database with [code]open_db()[/code]. If no database with this name exists, a new one at the supplied path will be created. Both [code]res://[/code] and [code]user://[/code] keywords can be used to define the path.
252
+
Path to the database. This is a read-only property that cannot be modified after opening the connection.
Contains the zErrMsg returned by the SQLite query in human-readable form. An empty string corresponds with the case in which the query executed succesfully.
0 commit comments