diff --git a/modules/database/doc_classes/Database.xml b/modules/database/doc_classes/Database.xml index 89f2377fd..be907c34b 100644 --- a/modules/database/doc_classes/Database.xml +++ b/modules/database/doc_classes/Database.xml @@ -1,20 +1,31 @@ + Represents a database. + Represents a database. + Classes inherited from it implement communication with database systems. + See [SQLite3Database] for an example. + Currently only an sqlite backend is available, however communication with other systems (like MySQL, or PostgreSQL) can be implemented without too much hassle using engine modules. + https://github.com/Relintai/pandemonium_demo_projects/tree/master/database/database_simple + https://github.com/Relintai/pandemonium_demo_projects/tree/master/database/prepared_statements + https://github.com/Relintai/pandemonium_demo_projects/tree/master/web + Returns a [DatabaseConnection] object which can be used to run queries on the database. + Always get a new one, don't store it, as the database backend might give different ones depending on certain factors (like calling threads) for faster operation. + Connection string used by the backend. diff --git a/modules/database/doc_classes/DatabaseConnection.xml b/modules/database/doc_classes/DatabaseConnection.xml index 57347a7b6..baed21e8a 100644 --- a/modules/database/doc_classes/DatabaseConnection.xml +++ b/modules/database/doc_classes/DatabaseConnection.xml @@ -1,8 +1,11 @@ + Represents a connection to a database server. + Represents a connection to a database server. + Don't create these directly, use the [code]get_connection()[/code] method in [Database] to get one. @@ -10,56 +13,69 @@ + Creates a [PreparedStatement] for use with this database connection. + Connect to the database. The backend will automatically call this. + Ensures that a table that contains the database's verison exists for compatibility checks. + Escapes the given [String] using the database backend's excape method. + Use it on user input for sanitization. + Note that [QueryBuilder] does this where necessary automatically. + Also note that when using [PreparedStatement]s this is not needed. + Returns the owner [Database]. + Returns a new [QueryBuilder] that is properly set up for this connection. + Returns a new [TableBuilder] that is properly set up for this connection. + Returns the current table version. This can be used to determine database compatibility, or for example whether to run migrations or not during startup. + Run a query. Use the resulting[QueryResult] object to read data from the database. + Run a query. @@ -67,6 +83,7 @@ + Sets the current table version. diff --git a/modules/database/doc_classes/DatabaseManager.xml b/modules/database/doc_classes/DatabaseManager.xml index bb5a2e9ca..e57488a3a 100644 --- a/modules/database/doc_classes/DatabaseManager.xml +++ b/modules/database/doc_classes/DatabaseManager.xml @@ -1,8 +1,11 @@ + Database Manager Singleton. + Database Manager Singleton. + Stores database connections that need to be accessible throughout the application. @@ -12,32 +15,38 @@ + Add a Database. If [code]set_as_default[/code] is true it will be set as default, which means it will be set to the [member ddb] property. + Returns a Database. + Returns how many databases are stored in the singleton. + Returns all Databases. + Calls the [code]initialized[/code] signal. + Not implemented currently. Will likely load databases from ProjectSettings. @@ -46,6 +55,7 @@ + Calls the [member migration] signal. @@ -53,31 +63,37 @@ + Removes a Database. + The default database. + Emitted when a [Database] is added. + Emitted when a [Database] is removed. + Emitted when default database is changed. + Can be emitted using the [member initialized] method after the database connections are set up. @@ -85,6 +101,7 @@ + Can be emitted using the [member migrate] method when the databse structure needs to be updated (or created). diff --git a/modules/database/doc_classes/DatabaseMultiThreaded.xml b/modules/database/doc_classes/DatabaseMultiThreaded.xml index 7ff3c2634..e5a3a53b3 100644 --- a/modules/database/doc_classes/DatabaseMultiThreaded.xml +++ b/modules/database/doc_classes/DatabaseMultiThreaded.xml @@ -1,8 +1,10 @@ + Contains helper methods for multi threaded database systems on the c++ side. Don't use it directly. + Contains helper methods for multi threaded database systems on the c++ side. Don't use it directly. diff --git a/modules/database/doc_classes/DatabaseSingleThreaded.xml b/modules/database/doc_classes/DatabaseSingleThreaded.xml index bf60ef794..1c99cf384 100644 --- a/modules/database/doc_classes/DatabaseSingleThreaded.xml +++ b/modules/database/doc_classes/DatabaseSingleThreaded.xml @@ -1,8 +1,10 @@ + Contains helper methods for single threaded database systems on the c++ side. + Contains helper methods for single threaded database systems on the c++ side. diff --git a/modules/database/doc_classes/QueryBuilder.xml b/modules/database/doc_classes/QueryBuilder.xml index e57e379de..757d0dc55 100644 --- a/modules/database/doc_classes/QueryBuilder.xml +++ b/modules/database/doc_classes/QueryBuilder.xml @@ -390,18 +390,36 @@ + Adds a placeholder for prepared statements statement. (psph = Prepared Statement PlaceHolder) + Equivalent to: + [codeblock] + result += "?"; + [/codeblock] + Adds a placeholder with id for prepared statements statement. + Equivalent to: + [codeblock] + if (id.is_valid_unsigned_integer()): + result += "?" + id; + else: + result += ":" + id; + [/codeblock] + Adds a raw placeholder for prepared statements statement. + Equivalent to: + [codeblock] + result += raw_id; + [/codeblock] @@ -484,6 +502,14 @@ + Add a prepared statement placeholder parameter to [code]UPDATE[/code] statements. + Equivalent to: + [codeblock] + result += col; + result += "="; + psph(); + result += ", "; + [/codeblock] @@ -491,6 +517,14 @@ + Add a prepared statement with id placeholder parameter to [code]UPDATE[/code] statements. + Equivalent to: + [codeblock] + result += col; + result += "="; + psphi(id); + result += ", "; + [/codeblock] @@ -498,6 +532,14 @@ + Add a raw prepared statement placeholder parameter to [code]UPDATE[/code] statements. + Equivalent to: + [codeblock] + result += col; + result += "="; + psphr(raw_id); + result += ", "; + [/codeblock] @@ -611,18 +653,36 @@ + Add a prepared statement placeholder parameter to a [code]VALUES[/code] statement. + Equivalent to: + [codeblock] + psph(); + result += ", "; + [/codeblock] + Add a prepared statement with id placeholder parameter to a [code]VALUES[/code] statement. + Equivalent to: + [codeblock] + psphi(id); + result += ", "; + [/codeblock] + Add a raw prepared statement placeholder parameter to a [code]VALUES[/code] statement. + Equivalent to: + [codeblock] + psphi(raw_id); + result += ", "; + [/codeblock] @@ -700,6 +760,14 @@ + Add a prepared statement placeholder parameter to a [code]WHERE[/code] statement. (wpb = where param bool) + Equivalent to: + [codeblock] + result += col; + result += "="; + psph(); + result += " "; + [/codeblock] @@ -707,6 +775,14 @@ + Add a prepared statement with id placeholder parameter to a [code]WHERE[/code] statement. (wpb = where param bool) + Equivalent to: + [codeblock] + result += col; + result += "="; + psphi(id); + result += " "; + [/codeblock] @@ -714,6 +790,14 @@ + Add a raw prepared statement placeholder parameter to a [code]WHERE[/code] statement. (wpb = where param bool) + Equivalent to: + [codeblock] + result += col; + result += "="; + psphr(raw_id); + result += " "; + [/codeblock] diff --git a/modules/database/doc_classes/QueryResult.xml b/modules/database/doc_classes/QueryResult.xml index 36632daa6..b4a565fb7 100644 --- a/modules/database/doc_classes/QueryResult.xml +++ b/modules/database/doc_classes/QueryResult.xml @@ -1,8 +1,10 @@ + Read the result from a query that were run on a [Database]. + Read the result from a query that were run on a [Database]. @@ -11,51 +13,60 @@ + Gets a [String] value from the index-th cell. + Gets a bool value from the index-th cell. + Gets a double value from the index-th cell. + Gets a float value from the index-th cell. + Gets a int value from the index-th cell. + Returns the current error message (if any). + Returns the last inserted row's id. On some database backends this needs to be requested in the query to be available. + Is the given cell null. + Read the next row. Returns true if success, false if no more rows available. diff --git a/modules/database/doc_classes/TableBuilder.xml b/modules/database/doc_classes/TableBuilder.xml index 2627aa669..9e941f91d 100644 --- a/modules/database/doc_classes/TableBuilder.xml +++ b/modules/database/doc_classes/TableBuilder.xml @@ -204,6 +204,7 @@ + Resets the result.