Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require( "mysql" )
- local db, error = mysql.connect("127.0.0.1", "username", "password", "database")
- if (db == 0) then print(tostring(error) .. "\n") return end
- print("connection opened - " .. db .. "!\n");
- test, isok, error = mysql.query(db, "SELECT * FROM names");
- if (test) then
- PrintTable(test)
- end
- if (!isok) then
- print(tostring(error) .. "\n");
- end
- test, isok, error = mysql.query(db, "SELECT 1 + 1");
- if (test) then
- PrintTable(test)
- end
- if (!isok) then
- print(tostring(error) .. "\n");
- end
- test, isok, error = mysql.query(db, "INSERT INTO names (SteamId,Name) VALUES('fuck me!','it worked')");
- if (test) then
- PrintTable(test)
- end
- if (!isok) then
- print(tostring(error) .. "\n");
- end
- local succ, error = mysql.disconnect(db)
- if (not succ) then
- print( error );
- end
- print("connection closed!\n");
Add Comment
Please, Sign In to add comment