Skip to content

Commit 76adb85

Browse files
committed
Refactor codebase
1 parent 5a59340 commit 76adb85

13 files changed

+689
-600
lines changed

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,19 @@ Additionally, a video tutorial by [Mitch McCollum (finepointcgi)](https://github
9999

100100
## Methods
101101

102-
- Boolean success = **open_db()**
102+
- ResultCode rc = **open_db()**
103103

104104
Open a new database connection. Multiple concurrently open connections to the same database are possible.
105105

106-
- Boolean success = **close_db()**
106+
- ResultCode rc = **close_db()**
107107

108108
Close the current database connection.
109109

110-
- Boolean success = **query(** String query_string **)**
110+
- ResultCode rc = **query(** String query_string **)**
111111

112112
Query the database using the raw SQL statement defined in `query_string`.
113113

114-
- Boolean success = **query_with_bindings(** String query_string, Array param_bindings **)**
114+
- ResultCode rc = **query_with_bindings(** String query_string, Array param_bindings **)**
115115

116116
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).
117117

@@ -121,7 +121,7 @@ Additionally, a video tutorial by [Mitch McCollum (finepointcgi)](https://github
121121
var column_name : String = "name";
122122
var query_string : String = "SELECT %s FROM company WHERE age < ?;" % [column_name]
123123
var param_bindings : Array = [24]
124-
var success = db.query_with_bindings(query_string, param_bindings)
124+
var rc = db.query_with_bindings(query_string, param_bindings)
125125
# Executes following query:
126126
# SELECT name FROM company WHERE age < 24;
127127
```
@@ -130,7 +130,7 @@ Additionally, a video tutorial by [Mitch McCollum (finepointcgi)](https://github
130130
131131
***NOTE**: Binding column names is not possible due to SQLite restrictions. If dynamic column names are required, insert the column name directly into the `query_string`-variable itself (see https://github.com/2shady4u/godot-sqlite/issues/41).*
132132
133-
- Boolean success = **create_table(** String table_name, Dictionary table_dictionary **)**
133+
- ResultCode rc = **create_table(** String table_name, Dictionary table_dictionary **)**
134134
135135
Each key/value pair of the `table_dictionary`-variable defines a column of the table. Each key defines the name of a column in the database, while the value is a dictionary that contains further column specifications.
136136
@@ -182,40 +182,40 @@ Additionally, a video tutorial by [Mitch McCollum (finepointcgi)](https://github
182182
183183
For more concrete usage examples see the `database.gd`-file as found in this repository's demo project.
184184
185-
- Boolean success = **drop_table(** String table_name **)**
185+
- ResultCode rc = **drop_table(** String table_name **)**
186186
187187
Drop the table with name `table_name`. This method is equivalent to the following query:
188188
```
189189
db.query("DROP TABLE "+ table_name + ";")
190190
```
191191
192-
- Boolean success = **insert_row(** String table_name, Dictionary row_dictionary **)**
192+
- ResultCode rc = **insert_row(** String table_name, Dictionary row_dictionary **)**
193193
194194
Each key/value pair of the `row_dictionary`-variable defines the column values of a single row.
195195
196196
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`.
197197
198-
- Boolean success = **insert_rows(** String table_name, Array row_array **)**
198+
- ResultCode rc = **insert_rows(** String table_name, Array row_array **)**
199199
200200
- Array selected_rows = **select_rows(** String table_name, String query_conditions, Array selected_columns **)**
201201
202202
Returns the results from the latest query **by value**; meaning that this property does not get overwritten by any successive queries.
203203
204-
- Boolean success = **update_rows(** String table_name, String query_conditions, Dictionary updated_row_dictionary **)**
204+
- ResultCode rc = **update_rows(** String table_name, String query_conditions, Dictionary updated_row_dictionary **)**
205205
206206
With the `updated_row_dictionary`-variable adhering to the same table schema & conditions as the `row_dictionary`-variable defined previously.
207207
208-
- Boolean success = **delete_rows(** String table_name, String query_conditions **)**
208+
- ResultCode rc = **delete_rows(** String table_name, String query_conditions **)**
209209
210-
- Boolean success = **import_from_json(** String import_path **)**
210+
- ResultCode rc = **import_from_json(** String import_path **)**
211211
212212
Drops all database tables and imports the database structure and content present inside of `import_path.json`.
213213
214-
- Boolean success = **export_to_json(** String export_path **)**
214+
- ResultCode rc = **export_to_json(** String export_path **)**
215215
216216
Exports the database structure and content to `export_path.json` as a backup or for ease of editing.
217217
218-
- Boolean success = **import_from_buffer(** PackedByteArray input_buffer **)**
218+
- ResultCode rc = **import_from_buffer(** PackedByteArray input_buffer **)**
219219
220220
Drops all database tables and imports the database structure and content encoded in JSON-formatted input_buffer.
221221
@@ -227,7 +227,7 @@ Additionally, a video tutorial by [Mitch McCollum (finepointcgi)](https://github
227227
228228
Can be used together with `import_from_buffer()` to implement database encryption.
229229
230-
- Boolean success = **create_function(** String function_name, FuncRef function_reference, int number_of_arguments **)**
230+
- ResultCode rc = **create_function(** String function_name, FuncRef function_reference, int number_of_arguments **)**
231231
232232
Bind a [scalar SQL function](https://www.sqlite.org/appfunc.html) to the database that can then be used in subsequent queries.
233233
@@ -246,8 +246,8 @@ Additionally, a video tutorial by [Mitch McCollum (finepointcgi)](https://github
246246
db.compileoption_used("ENABLE_FTS5") # The "SQLITE_"-prefix may be omitted.
247247
```
248248
249-
- Boolean success = **backup_to(** String destination_path **)**
250-
- Boolean success = **restore_from(** String source_path **)**
249+
- ResultCode rc = **backup_to(** String destination_path **)**
250+
- ResultCode rc = **restore_from(** String source_path **)**
251251
252252
Backup or restore the current database to/from a path, see [here](https://www.sqlite.org/backup.html). This feature is useful if you are using a database as your save file and you want to easily implement a saving/loading mechanic. Be warned that the original database will be overwritten entirely when restoring.
253253

0 commit comments

Comments
 (0)