diff --git a/database.rst b/database.rst index 68fb9f6..4fb5953 100644 --- a/database.rst +++ b/database.rst @@ -6,17 +6,6 @@ Both the Legacy mod and the ET:Legacy engine are built-in with `SQLite3 `__ sample code for an example of basic database usage. -If desired, Lua scripts can also connect to the engine memory database by the following Lua command:: - - --[[ - Lua Example connecting to engine database - --]] - con = assert (env:connect( "file::memory:?cache=shared")) - -.. Note:: The database is only active when the `db_mode `_ cvar is set. - -To save this in memory database to disk use the **saveDB** console command. See also the `db_url `_ cvar to specify the database path. - Error handling ============== @@ -73,8 +62,21 @@ The sourcename may vary according to each driver. SQLite3 uses a simple database .. Some use a simple database name, like PostgreSQL, MySQL and SQLite; the ODBC driver expects the name of the DSN; the Oracle driver expects the service name; See also: PostgreSQL, and MySQL extensions. + -- database path + local dbpath = string.gsub(et.trap_Cvar_Get("fs_homepath"), "\\", "/").."/"..et.trap_Cvar_Get("fs_game").."/" + -- connection + conn = assert(env:connect(dbpath .. "etl.db")) + Returns a `connection object `__. +If desired, Lua scripts can also connect to the engine memory database by the following Lua command:: + + conn = assert(env:connect("file::memory:?cache=shared")) + +.. Note:: The database is only active when the `db_mode `_ cvar is set. + +To save this in memory database to disk use the **saveDB** console command. See also the `db_url `_ cvar to specify the database path. + Connection objects ==================