Garry's Mod Wiki

Revision Difference

sql#548969

<type name="sql" category="libraryfunc" is="library"> <summary>The SQL library allows you to access powerful database software included with Garry's Mod. It is the preferred and fastest method of storing large amounts of data. The database is located in sv.db serverside and cl.db clientside, both in the Garry's Mod base folder. SQL is a whole scripting language in itself although relatively simple, it's something you'll need to read up on before using this library. Example of using sql. ``` -- Creating a table sql.Query("CREATE TABLE my_db_table( id NUMBER , name TEXT )" ) -- Inserting a value to the table sql.Query("INSERT INTO my_db_table( id , name ) VALUES( 1 , 'First') ") -- Printing the tables data PrintTable( sql.Query("SELECT * FROM my_db_table ") ) -- Deleting the table sql.Query("DROP TABLE my_db_table") ``` Known GMod [SQL settings](https://www.sqlite.org/compile.html):⤶ Known GMod [SQLite](https://www.sqlite.org/compile.html) settings:⤶ * Temp files are stored in memory (`SQLITE_TEMP_STORE = 3`) * No `ATTACH` and `DETACH` operations (`SQLITE_OMIT_ATTACH = 1`) * No Virtual Tables (`SQLITE_OMIT_VIRTUALTABLE = 1`) * No `VACUUM` operation (`SQLITE_OMIT_VACUUM = 1`) * No `LIMIT` and `ORDER BY` clauses in `DELETE` and `UPDATE` statements (`SQLITE_ENABLE_UPDATE_DELETE_LIMIT`)</summary> </type>