1. Post #81
    syl0r's Avatar
    January 2012
    414 Posts
    Yeah. I did use wget though and chmod +x on it. Do you think that may be why?
    When using wget you have to use the direct link (https://github.com/syl0r/MySQLOO/raw...qloo_linux.dll)
    Otherwise it just downloads an html file which is obviously why it doesn't work.

  2. Post #82

    January 2012
    22 Posts
    Nevermind me! I fixed it. The issue was when I initially downloaded the files through wget, I didn't specify the raw URL. It downloaded html instead.

    I retried it with the so.18.3.0, but it only worked with the so.18, so I used that one.

    Linux install for those who also might want it, where server_1 is your root folder with srcds_linux:

    Code:
    cd ~/server_1
    wget https://raw.githubusercontent.com/syl0r/MySQLOO/master/MySQL/lib/linux/libmysqlclient.so.18
    chmod +x ./libmysqlclient.so.18
    cd ./garrysmod/lua
    mkdir -p bin
    cd ./bin
    wget https://raw.githubusercontent.com/syl0r/MySQLOO/master/out/linux/gmsv_mysqloo_linux.dll
    chmod +x ./gmsv_mysqloo_linux.dll
    Thanks sly0r

    Edited:

    When using wget you have to use the direct link (https://github.com/syl0r/MySQLOO/raw...qloo_linux.dll)
    Otherwise it just downloads an html file which is obviously why it doesn't work.
    Beat me to it. I'm slow.

  3. Post #83
    YukiTheater.org
    WinterPhoenix's Avatar
    January 2013
    119 Posts
    A few years ago, I used to use MySQLOO 8 for my server (circa 2013), but switched over to tmysql4 after experiencing the utterly depressing performance and lack of stability MySQLOO had at the time.

    I understand that MySQLOO has been greatly rewritten for this version update, so seeing as tmysql4 is no longer actively developed, nor does it have prepared statements or ensured query execution order, in what ways/in what scenarios is MySQLOO 9 slower than tmysql4? Furthermore, how stable is it as it stands right now?

  4. Post #84
    syl0r's Avatar
    January 2012
    414 Posts
    You should never notice any speed difference between mysqloo and tmysql except for the fact that tmysql used two connections per database instance (which is a bad thing).

    The current mysqloo9 version should be perfectly stable. I run it on my own server since ~1 year and I haven't noticed any crashes caused by it. I will probably release an update to the module today or tomorrow that is going to change a lot of things (while maintaining full backwards compatibility) but even that should be mostly stable.
    If you do however notice any crashes that you think might be related to this module feel free to post about it in this thread.
    Reply With Quote Edit / Delete Reply Windows 10 Chrome Germany Show Events Useful Useful x 3Disagree Disagree x 1 (list)

  5. Post #85

    January 2017
    7 Posts
    Hey, anyone here who could help me with a little problem with this version of mysqloo?
    I'm not sure if I'm using the database:ping() correctly.. currently I don't see any way to reconnect to a database after the connection is lost while server is on.

    I posted a thread here, please see for further information:
    https://facepunch.com/showthread.php?t=1548244


    Thanks!

  6. Post #86
    syl0r's Avatar
    January 2012
    414 Posts
    Hey, anyone here who could help me with a little problem with this version of mysqloo?
    The problem is that mysqloo does not attempt to automatically reconnect to the database if the database connection failed initially. This is because mysqloo doesn't know that the connection can even be established successfully (i.e. wrong credentials) so it would be a problem to try to automatically reconnect even in those cases.
    To fix your problem you have to recreate the db using mysqloo.connect() if the connection fails.


    I also just released a new update that changes many things, the most important being that you can reuse query objects and start them multiple times:
    local query = db:query("UPDATE counter_tbl SET counter = counter + 1")
    query:start()
    query:start()
    

    This is especially useful for prepared queries as they can reuse the statement handle allocated on the database server:
    local query = db:prepare("INSERT INTO logs (`message`) VALUES(?)")
    query:setString(1, "hello")
    query:start()
    query:setString(2, "world")
    query:start()
    

    It even calls the callbacks you'd expect every time as long as you always set the callbacks before you start the query.
    local ply1 = player.GetAll()[1]
    local query = db:prepare("SELECT rank FROM users WHERE steamid = ?")
    query:setString(1, ply1:SteamID())
    function query:onSuccess(data)
    	//This will set the rank of ply1
    	ply1:SetRank(data[1].rank)
    end
    query:start()
    local ply2 = player.GetAll()[2]
    query:setString(1, ply2:SteamID())
    function query:onSuccess(data)
    	//This will set the rank of ply2
    	ply2:SetRank(data[1].rank)
    end
    query:start()
    
    Reply With Quote Edit / Delete Reply Windows 10 Chrome Germany Show Events Winner Winner x 6 (list)

  7. Post #87
    bigdogmat's Avatar
    May 2014
    589 Posts
    The update notes said that prepared queries can now return multiple result sets, however when trying to do something such as

    Code:
    local a = database:prepare "SELECT 1, 2; SELECT 3, 4"
    
    function a:onError(err, sql)
      MsgN(err, "\n\n", sql)
    end
    
    function a:onSuccess(data)
    
      while self:hasMoreResults() do
        PrintTable(data)
        data = self:getNextResults()
      end
    end
    
    a:start()
    I get

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 3, 4' at line 1

    SELECT 1, 2; SELECT 3, 4

  8. Post #88
    syl0r's Avatar
    January 2012
    414 Posts
    Prepared statements can only ever represent one statement (hence the name).
    You can still get multiple result sets without having multiple statements by calling a stored procedure.
    So I would recommend either creating a stored procedure that does what you want or to use two prepared queries in a transaction.

  9. Post #89
    bigdogmat's Avatar
    May 2014
    589 Posts
    Prepared statements can only ever represent one statement (hence the name).
    You can still get multiple result sets without having multiple statements by calling a stored procedure.
    Ah, thanks for the information, also, probably worth noting ErrorNoHalt needs a newline on the end for callback errors.

  10. Post #90

    January 2017
    7 Posts
    The problem is that mysqloo does not attempt to automatically reconnect to the database if the database connection failed initially. This is because mysqloo doesn't know that the connection can even be established successfully (i.e. wrong credentials) so it would be a problem to try to automatically reconnect even in those cases.
    To fix your problem you have to recreate the db using mysqloo.connect() if the connection fails.
    I tried adding these two lines of code to my db:onConnectionFailed timer:

    db = mysqloo.connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME, DATABASE_PORT)
    db:connect()
    
    It still keeps printing "false" with the db:ping() all the time while my databse is online and I can access it fine on phpMyAdmin. (And so can the server if it's started while database is already online)

  11. Post #91
    syl0r's Avatar
    January 2012
    414 Posts
    Then you must have wrong credentials. Try printing the error message.

  12. Post #92

    January 2017
    7 Posts
    Then you must have wrong credentials. Try printing the error message.
    This is my unchanged code. Credentials are correct because it connects successfully if I start the server while database is already online.

    The error message from db:onConnectionFailed is always the same, whether my databse is online or offline.
    "Can't connect to MySQL server on 'localhost'"

    Also I'll just clarify again, this only occurs if I start server while database is offline. Otherwise it works.

    require ("mysqloo")
    
    local DATABASE_HOST = "localhost"
    local DATABASE_PORT = 3306
    local DATABASE_NAME = "bleur"
    local DATABASE_USERNAME = "root"
    local DATABASE_PASSWORD = "pass"
    
    
    local db = mysqloo.connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME, DATABASE_PORT)
    
    function db:onConnected( )
    		if timer.Exists("pingdb") then
    			timer.Remove("pingdb")
    		end
    		MsgC( Color( 255, 255, 0 ), "Successfully connected to the MySQL Database\n" )
    end
    
    function db:onConnectionFailed( err )
    		MsgC( Color( 255, 255, 0 ), "Connection to the MySQL Database failed\nError: ", err, "\n")
    		timer.Create("pingdb", 5, 0, function()
    			print("Retrying connection to database...")
    			db = mysqloo.connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME, DATABASE_PORT)
    			db:connect()
    			db:ping()
    			print (db:ping(),"\n")
    		end)
    end
    
    db:connect()
    

  13. Post #93
    syl0r's Avatar
    January 2012
    414 Posts
    The problem is that you are creating a new database instance but you aren't setting the callbacks again. This will mean onConnected will not be called and your timer will just retry every 5 seconds.
    Additionally db:ping() does only work _after_ the connection has been established. Since db:connect() doesn't wait for the connection to finish db:ping() will probably run before that and return false every time.

  14. Post #94

    January 2017
    7 Posts
    The problem is that you are creating a new database instance but you aren't setting the callbacks again. This will mean onConnected will not be called and your timer will just retry every 5 seconds.
    Additionally db:ping() does only work _after_ the connection has been established. Since db:connect() doesn't wait for the connection to finish db:ping() will probably run before that and return false every time.
    Thank you!