Controls the target database type used at runtime.
Possible values (case insensitive):
MYSQL
POSTGRESQL
SQLITE
Example
Host name where the database resides. Typically localhost
but can be any valid host name or IP address.
Not used if using SQLite.
Example
The port for the database connection. If left unset it will use the default port.
Only used by MySQL.
Example
Database username used for the connection.
Not used if using SQLite.
Example
Password for the database connection.
Not used if using SQLite.
Example
The database to connect to.
The filename of the database when using SQLite, it is stored in the UserDirectory/database folder.
Example
Export query execution metrics.
The Metrics_InfluxDB plugin and a visualizer like Grafana are required to view these metrics.
Example
Convert all strings going between the database and game to/from UTF8
This takes into account the core locale as well.
Example
Set the connection's character set to be used.
Only supported on mysql and pgsql. For sqlite this can be achieved with a query.
Examples (MySQL)
Examples (PostgreSQL)
(see https://www.postgresql.org/docs/current/multibyte.html for list)
Files | |
file | nwnx_sql.nss |
Functions | |
int | NWNX_SQL_PrepareQuery (string query) |
Prepares the provided query for execution. More... | |
int | NWNX_SQL_ExecutePreparedQuery () |
Executes a query which has been prepared. More... | |
int | NWNX_SQL_ExecuteQuery (string query) |
Directly execute an SQL query. More... | |
int | NWNX_SQL_ReadyToReadNextRow () |
void | NWNX_SQL_ReadNextRow () |
Reads the next row of returned data. More... | |
string | NWNX_SQL_ReadDataInActiveRow (int column=0) |
void | NWNX_SQL_PreparedInt (int position, int value) |
Set the int value of a prepared statement at given position. More... | |
void | NWNX_SQL_PreparedString (int position, string value) |
Set the string value of a prepared statement at given position. More... | |
void | NWNX_SQL_PreparedFloat (int position, float value) |
Set the float value of a prepared statement at given position. More... | |
void | NWNX_SQL_PreparedObjectId (int position, object value) |
Set the ObjectId value of a prepared statement at given position. More... | |
void | NWNX_SQL_PreparedObjectFull (int position, object value, int base64=TRUE) |
Set the full serialized object value of a prepared statement at given position. More... | |
void | NWNX_SQL_PreparedNULL (int position) |
Set the NULL value of a prepared statement at given position. More... | |
void | NWNX_SQL_PreparedJson (int position, json value) |
Set the Json value of a prepared statement at given position. Convienence function to match other Prepared(type) functions. More... | |
object | NWNX_SQL_ReadFullObjectInActiveRow (int column=0, object owner=OBJECT_INVALID, float x=0.0, float y=0.0, float z=0.0, int base64=TRUE) |
Like NWNX_SQL_ReadDataInActiveRow, but for full serialized objects. More... | |
int | NWNX_SQL_GetAffectedRows () |
Gets the rows affected by a query. More... | |
string | NWNX_SQL_GetDatabaseType () |
void | NWNX_SQL_DestroyPreparedQuery () |
Free any resources attached to an existing prepared query. More... | |
string | NWNX_SQL_GetLastError () |
int | NWNX_SQL_GetPreparedQueryParamCount () |
Gets the number of parameteres expected by a prepared query. More... | |
void | NWNX_SQL_PostgreSQL_SetNextQueryResultsBinaryMode () |
Set the next query to return full binary results ON THE FIRST COLUMN ONLY. More... | |
int NWNX_SQL_PrepareQuery | ( | string | query | ) |
Prepares the provided query for execution.
query | The query to prepare. |
Definition at line 117 of file nwnx_sql.nss.
int NWNX_SQL_ExecutePreparedQuery | ( | ) |
Executes a query which has been prepared.
Definition at line 126 of file nwnx_sql.nss.
int NWNX_SQL_ExecuteQuery | ( | string | query | ) |
Directly execute an SQL query.
Definition at line 134 of file nwnx_sql.nss.
int NWNX_SQL_ReadyToReadNextRow | ( | ) |
Definition at line 147 of file nwnx_sql.nss.
void NWNX_SQL_ReadNextRow | ( | ) |
Reads the next row of returned data.
Definition at line 155 of file nwnx_sql.nss.
string NWNX_SQL_ReadDataInActiveRow | ( | int | column = 0 | ) |
column | The column to read in the active row. |
Definition at line 162 of file nwnx_sql.nss.
void NWNX_SQL_PreparedInt | ( | int | position, |
int | value | ||
) |
Set the int value of a prepared statement at given position.
position | The nth ? in a prepared statement. |
value | The value to set. |
Definition at line 172 of file nwnx_sql.nss.
void NWNX_SQL_PreparedString | ( | int | position, |
string | value | ||
) |
Set the string value of a prepared statement at given position.
position | The nth ? in a prepared statement. |
value | The value to set. |
Definition at line 180 of file nwnx_sql.nss.
void NWNX_SQL_PreparedFloat | ( | int | position, |
float | value | ||
) |
Set the float value of a prepared statement at given position.
position | The nth ? in a prepared statement. |
value | The value to set. |
Definition at line 188 of file nwnx_sql.nss.
void NWNX_SQL_PreparedObjectId | ( | int | position, |
object | value | ||
) |
Set the ObjectId value of a prepared statement at given position.
position | The nth ? in a prepared statement. |
value | The value to set. |
Definition at line 196 of file nwnx_sql.nss.
void NWNX_SQL_PreparedObjectFull | ( | int | position, |
object | value, | ||
int | base64 = TRUE |
||
) |
Set the full serialized object value of a prepared statement at given position.
position | The nth ? in a prepared statement. |
value | The value to set. |
base64 | Use base64-encoded string format if TRUE (default), otherwise use binary format. |
Definition at line 204 of file nwnx_sql.nss.
void NWNX_SQL_PreparedNULL | ( | int | position | ) |
Set the NULL value of a prepared statement at given position.
position | The nth ? in a prepared statement. |
Definition at line 213 of file nwnx_sql.nss.
void NWNX_SQL_PreparedJson | ( | int | position, |
json | value | ||
) |
Set the Json value of a prepared statement at given position. Convienence function to match other Prepared(type) functions.
position | The nth ? in a prepared statement. |
value | The value to set. |
Definition at line 220 of file nwnx_sql.nss.
object NWNX_SQL_ReadFullObjectInActiveRow | ( | int | column = 0 , |
object | owner = OBJECT_INVALID , |
||
float | x = 0.0 , |
||
float | y = 0.0 , |
||
float | z = 0.0 , |
||
int | base64 = TRUE |
||
) |
Like NWNX_SQL_ReadDataInActiveRow, but for full serialized objects.
The object will be deserialized and created in the game. New object ID is returned.
The exact behavior depends on type of deserialized object and owner object:
column | The column to read in the active row. |
owner | The owner of the object. |
x,y,z | The vector for objects to be placed in areas. |
base64 | Use base64-encoded string format if TRUE (default), otherwise use binary format. |
Definition at line 228 of file nwnx_sql.nss.
int NWNX_SQL_GetAffectedRows | ( | ) |
Gets the rows affected by a query.
Definition at line 242 of file nwnx_sql.nss.
string NWNX_SQL_GetDatabaseType | ( | ) |
Gets the database type.
Definition at line 250 of file nwnx_sql.nss.
void NWNX_SQL_DestroyPreparedQuery | ( | ) |
Free any resources attached to an existing prepared query.
Definition at line 258 of file nwnx_sql.nss.
string NWNX_SQL_GetLastError | ( | ) |
Definition at line 265 of file nwnx_sql.nss.
int NWNX_SQL_GetPreparedQueryParamCount | ( | ) |
Gets the number of parameteres expected by a prepared query.
Definition at line 273 of file nwnx_sql.nss.
void NWNX_SQL_PostgreSQL_SetNextQueryResultsBinaryMode | ( | ) |
Set the next query to return full binary results ON THE FIRST COLUMN ONLY.
Definition at line 281 of file nwnx_sql.nss.