1. So i was using old Query function with returning result dictionary<string,string>, but with latest oxide update it not working anymore. Why old functions was removed at all and replaced with "QueryAsync"? Its not very good to use in case when i want return result in function because now it forces to use callback everywhere and all my code is broken. Also i'm not really know how to use Action<List<Dictionary<string, object>>> at all.
     
    Last edited by a moderator: Aug 13, 2015
  2. The old sync functions were removed because they blocked the server ticking. Which is a real issue on slow or highly used connection to the mysql server.

    I've updated the examples here:
    http://oxidemod.org/extensions/mysql-extension.901/

    It should not be too hard to update to the new api.
     
  3. Ok, thank you for link, got what i needed, but still need bit rewrite my code because didn't expected do it async at all.
     
  4. A similar problem. Changed, but not working.
    Code:
    [Oxide] 4:17 AM [Warning] Already open connection (server=localhost;port=3306;database=base;user id=login;password=pass;pooling=False;characterset=utf8), using existing instead...
    [DOUBLEPOST=1439517290][/DOUBLEPOST]Code plugin:
    Code:
    function PLUGIN:cmdPassword(player,cmd,args)
        local array = {}
      
        if (args.Length == 0) then
            rust.SendChatMessage(player, "Pass", "Write password")
        else
            self.mysqldb = mysql.OpenDb = mysql.OpenDb("localhost", 3306, "base", "login", "pass",  self.Plugin, false)
            local sql = mysql.NewSql()
            sql:Append("UPDATE `db_users` SET `password`='"..args[0].."' WHERE `steam_id`="..rust.UserIDFromPlayer(player))
            local query = mysql.Insert(sql,self.mysqldb)
        rust.SendChatMessage(player, "Pass", "Password changed")
        end
    end
     
  5. Should actually work. Have you checked if the password is updated in db?
    Insert has no return, if you need the result you will have to use the callback.
    The warning occurs because you are opening/creating the mysql connection with every function call. You just need to do it once. Like open in OnServerInitialized and close in Unload.
     
  6. That's right?
    [DOUBLEPOST=1439519163][/DOUBLEPOST]I apologize to the 10 lines written twice
    = mysql.OpenDb
    :)
    [DOUBLEPOST=1439519401][/DOUBLEPOST]Not work:(
     

    Attached Files:

  7. There is problem on oxide side, now all my plugins also stop work and just don't run query at all. Don't know why, no any errors or anything that can explain why it not work.

    Even this simple plugin don't retry anything, but login and password correct.

    Code:
    using Oxide.Core;
    using Oxide.Ext.MySql;
    using Oxide.Ext.MySql.Libraries;namespace Oxide.Plugins
    {
        [Info("test", "AlexALX", "0.0.1")]
        public class Donat : RustPlugin
        {
            private Connection db;
            private Ext.MySql.Libraries.MySql mysql = Interface.Oxide.GetLibrary<Ext.MySql.Libraries.MySql>("MySql");
         
            void Loaded()
            {
                db = mysql.OpenDb("localhost", 3306, "test", "test", "123", this);
                var sql = mysql.NewSql().Append("UPDATE `db_users` SET `onl`='1'");
                mysql.Update(sql,db);
                var sql = mysql.NewSql().Append("SELECT * FROM `db_users`");
                mysql.Query(sql,db,data => {
                    Puts(data.ToString());
                });
            } 
        }
     
    }
    If run query in phpmyadmin everything works fine.
    [DOUBLEPOST=1439526412][/DOUBLEPOST]Wait found this

    Code:
    6:52 AM [Error] MySql handle raised an exception (NullReferenceException: Object reference not set to an instance of an object)
    6:52 AM [Debug]   at Oxide.Ext.MySql.Libraries.MySql+MySqlQuery.Handle () [0x00000] in <filename unknown>:0 
    And it seems after this in stop work. Don't remember when this happens.
    [DOUBLEPOST=1439526756][/DOUBLEPOST]After server restart it start work again, so it seems like error what i found is actually some problem in mysql library or so, don't know.
     
  8. Wulf

    Wulf Community Admin

  9. I have the same thing
     
  10. Wulf

    Wulf Community Admin

    Which Oxide build are you using?
     
  11. 2.0.1290
     
  12. Wulf

    Wulf Community Admin

  13. Wulf

    Wulf Community Admin

  14. thank you very much
    [DOUBLEPOST=1439656050][/DOUBLEPOST]
    Code:
    [Oxide] 7:25 PM [Error] MySql handle raised an exception (NullReferenceException: Object reference not set to an instance of an object)
    [Oxide] 7:25 PM [Debug]   at Oxide.Ext.MySql.Libraries.MySql+MySqlQuery.Handle () [0x00000] in <filename unknown>:0
    same thing =(
    [DOUBLEPOST=1439663583,1439654890][/DOUBLEPOST]do something, please
     
  15. can you provide a full example plugin where this error occurs? so far i was not able to reproduce your issue...
     
  16. private messages
     
  17. I am having issues pulling a query(not sure if its my lack of experience) but I am able to insert into the table. Here is the query I am trying to pull

    Code:
    [ChatCommand("mysql")]
            private void mysqlCmd(BasePlayer player, string command)
            {
                _SteamID = player.userID.ToString();
                _SteamName = player.displayName;
                var sql = Ext.MySql.Sql.Builder.Append(@"
                                   CREATE TABLE IF NOT EXISTS player_info (
                                     id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
                                     SteamID VARCHAR(80),
                                     SteamName VARCHAR(100)
                                   );");           // sql.Append(InsertData, _SteamID, _SteamName);
               // _mySql.Update(sql, _mySqlConnection);            sql.Append(SelectData, _SteamName);
                _mySql.Query(sql, _mySqlConnection, list =>
                {                if (list == null) return;
                            var sb = new StringBuilder();
                            sb.AppendLine();
                            sb.AppendLine(" id\tdata\t\tdata_other");
                            foreach (var entry in list)
                            {
                                sb.AppendFormat(" {0}\t{1}\t{2}", entry["steam"], entry["SteamName"], entry["data_other"]);
                                sb.AppendLine();
                            }
                            Puts(sb.ToString());
                        });
              
                      }
    
    I was able to get one output of this
    Code:
    [Oxide] 7:44 AM [Info] [Rust Life]
    id    data        data_other
    
    Unfortunately , I changed something and now cant reproduce that same output and just recieve this error.
    error I am now getting
    Code:
    [Oxide] 8:07 AM [Error] MySql command callback raised an exception (KeyNotFoundException: The given key was not present in the dictionary.)
    [Oxide] 8:07 AM [Debug]   at System.Collections.Generic.Dictionary`2[System.String,System.Object].get_Item (System.String key) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.RustLife.<mysqlCmd>m__0 (System.Collections.Generic.List`1 list) [0x00000] in <filename unknown>:0
      at Oxide.Ext.MySql.Libraries.MySql+MySqlQuery+<Handle>c__AnonStorey0.<>m__0 () [0x00000] in <filename unknown>:0 
    I finally got the return, it was my fault and the misuage of the Append line , and the correct amount of variables.
     
    Last edited by a moderator: Aug 16, 2015