PostgresConnection (Lua/Minetest) 🔗
A simple Lua wrapper for PostgreSQL using a C library (luapg.so
) for Minetest.
Functions 🔗
PostgresConnection.new(host, dbname, user, password)
🔗
Creates a new connection to a PostgreSQL database.
Returns:
PostgresConnection
object on successnil, error_message
on failure
PostgresConnection.new_from_conf(config_path)
🔗
Creates a new connection using a configuration file.
Returns:
PostgresConnection
object on successnil, error_message
if config file is missing or empty
PostgresConnection:execute(query)
🔗
Executes a non-select SQL query (INSERT
, UPDATE
, DELETE
, etc.).
Returns:
true
on successfalse, error_message
on failure
PostgresConnection:select(query)
🔗
Executes a SELECT
query and returns the resulting rows.
Returns:
table
of rows on successnil, error_message
on failure
PostgresConnection:escape(text, escaping_type)
🔗
Escapes a string or identifier for safe usage in SQL queries.
Parameters:
text
(string) – the value or identifier to escapeescaping_type
(string) –"value"
for SQL values,"identifier"
for table/column names (defaults to"value"
if invalid)
Returns:
- Escaped string on success
nil, error_message
on failure