--- Defaults relating to the sql database. -- If you need to change the defaults, nrequire() thi -- module, then change any of the fields. -- @server sv_sql.lua local sql = {} --SQL stuff, be careful to keep this secret! --- The values in the sql table -- @table mysql_config -- @field boolean EnableMySQL=true Should we use MySQLOO to store the data? -- @field string Host=localhost The hostname that the mysql database lives on -- @field string Username=root The username to log into the database -- @field string Password=root The password to log into the database -- @field number Database_port=3306 The port to connect to the database on -- @field string Preferred_module=mysqloo The perfered module to use for sql, when multiple are avaliable. local parse = { ["EnableMySQL"] = tobool, ["Host"] = tostring, ["Username"] = tostring, ["Password"] = tostring, ["Database_name"] = tostring, ["Database_port"] = tonumber, ["Preferred_module"] = tostring, [""] = function() return nil end } local default_file = [[ EnableMySQL=false Host=localhost Username=root Password=root Database_name=artery Database_port=3306 Preferred_module=mysqloo ]] local mysqlconfig = file.Read("artery/mysql.txt") if not mysqlconfig then file.Write("artery/mysql.txt",default_file) error("No sql setup defined, a default config has been given. edit garrysmod/data/artery/mysql.txt to configure it.") end for _,line in pairs(string.Explode("\n",mysqlconfig,false)) do local key, value = unpack(string.Explode("=",line,false)) assert(parse[key],string.format("SQL field unknown:%q known fields:\n\t%s",key,table.concat(table.GetKeys(parse),"\n\t"))) sql[key] = parse[key](value) end return sql