Skip to content
rebel1324 edited this page Dec 25, 2014 · 1 revision

This library helps you to integrate with MySQL Database / SQLite Database in your server. As usual, we don't recommend external sql server for the gamemode. The database should be not able to access from outside of server.

This Library is SERVERSIDE, which means you can't access to any kind of stuffs in this library in the client.

Configuration

To configure this nutscript's database connection information, you need to go sv_database.lua or create new serverside config lua file on your schema and copy and paste sv_database.lua and configure the stuffs in there.

Most Local Server Owner does not requires any kind of database configuration. Only the owner who runs multiple server or server hosting that does not supports SQLite requires to do configuration.

The sv_database.lua file is located in Nutscript/gamemode/config/sv_database.lua. In the Repo, You can find it in Here.

Methods

  • nut.db.connect(callback)
  • For internal usage. You don't have to and must not call this function twice.
  • nut.db.wipeTables()
  • RESETS THE DATABASE. Requires additional care for this function. Do not ever use RunString based console command to save your database.
  • nut.db.loadTables()
  • For internal usage. Creates Default Tables.
  • nut.db.convertDataType(value)
  • Converts data to certain type which is more suitable to save in SQL Database.
  • nut.db.insertTable(value, callback, dbTable)
  • Inserts a row in the certain table with the callback. This is the function that you're going to use mostly.
  • nut.db.updateTable(value, callback, dbTable, condition)
  • Updates a row in the certain table with the callback. This is the function that you're going to use mostly.
  • nut.db.query(DROP_QUERY, callback)
  • Runs Query on Database Server with the callback. This is the function that you're going to use mostly.

Clone this wiki locally