Dispatch SQL queries via Serverconsole, Clientconsole, Chat or RCON
Available commands can only be used by root admins (flag Z) if dispatched from a client.
sql_connect_sqlite
connect to local sqlite database
usage: sql_connect_sqlite <\"dbname\"> <CreateIfNonExistant - 1|0 - default:0>
sql_connect_section
connect to db listed in configs/databases.cfg
usage: sql_connect_section <\"databases.cfg section\">
sql_connect_custom
connect with custom settings
usage: sql_connect_custom <dbtype(sqlite|mysql)> <\"hostname/ip\"> <\"database\"> <\"username\"> <\"password\"> <\"port\">
sql_disconnect
disconnect
usage: sql_disconnect (no arguments)
sql_query
dispatch sql query
usage: sql_query "query string"
Only the first result set will be returned if there are more than one.
The command loops through all rows and columns and prints them out.
You should avoid queries with big resultsets, as this WILL lag the server because of a buttload of string concatenation.
You can put "sql_connect*whatever*" to your servers autoexec.cfg if you like, so you can quickly send queries to your main db whenever you feel like.
A typical console printout while using this plugin might look like this:
Code:
] sql_connect_sqlite dignatio
Can't select character set (SET NAMES 'utf8')
DatabaseInit SQLLITE (CONNECTED)
SQLITE_VERSION()
----------------
3.5.1
Tables
------
Accuracy
Map
Player
countrylist
data
] sql_query "SELECT name,points FROM Player"
NAME|POINTS
-----------
Timiditas|44
] sql_query "update Player set points = 0 where name = 'Timiditas'"
Affected rows: 1
] sql_disconnect
Plugin updated, fixed runtime error on queries with no resultset (UPDATE, DELETE,INSERT...)