diff --git a/database.rst b/database.rst index 1ae163e..3991db0 100644 --- a/database.rst +++ b/database.rst @@ -58,13 +58,15 @@ env:connect(sourcename[,username[,password]]) --------------------------------------------- Connects to a data source specified in sourcename using username and password if they are supplied. -The sourcename may vary according to each driver. SQLite3 uses a simple database name. +The sourcename may vary according to each driver. SQLite3 uses a simple database name:: + + -- get 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")) .. 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. - local dbpath = string.gsub(et.trap_Cvar_Get("fs_homepath"), "\\", "/").."/"..et.trap_Cvar_Get("fs_game").."/" - 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::