Guest User

Untitled

a guest
May 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. require( "mysql" )
  2.  
  3. local db, error = mysql.connect("127.0.0.1", "username", "password", "database")
  4. if (db == 0) then print(tostring(error) .. "\n") return end
  5.  
  6. print("connection opened - " .. db .. "!\n");
  7.  
  8. test, isok, error = mysql.query(db, "SELECT * FROM names");
  9. if (test) then
  10. PrintTable(test)
  11. end
  12. if (!isok) then
  13. print(tostring(error) .. "\n");
  14. end
  15.  
  16. test, isok, error = mysql.query(db, "SELECT 1 + 1");
  17. if (test) then
  18. PrintTable(test)
  19. end
  20. if (!isok) then
  21. print(tostring(error) .. "\n");
  22. end
  23.  
  24. test, isok, error = mysql.query(db, "INSERT INTO names (SteamId,Name) VALUES('fuck me!','it worked')");
  25. if (test) then
  26. PrintTable(test)
  27. end
  28. if (!isok) then
  29. print(tostring(error) .. "\n");
  30. end
  31.  
  32. local succ, error = mysql.disconnect(db)
  33. if (not succ) then
  34. print( error );
  35. end
  36. print("connection closed!\n");
Add Comment
Please, Sign In to add comment