• tmysql4 - A multi-connection version of tmysql3 (Now with mysqloo wrapper!)
    384 replies, posted
Oh.. Now that is strange. I thought ULX used mysqloo or something based on what you were saying. It shouldn't conflict with anything, but I'm not completely certain..
[QUOTE=BlackAwps;49463322]Oh.. Now that is strange. I thought ULX used mysqloo or something based on what you were saying. It shouldn't conflict with anything, but I'm not completely certain..[/QUOTE] ULX doesn't use anything with MySQL, whatever he is using is some extra addon.
[QUOTE=BlackAwps;49463254]Doing that would be terrible, slow, and inefficient. This module allows you to communicate with a mysql server directly, allowing you to fetch and update data directly without a middleman. If you wan't prepared statements, do something like in this post. [URL]https://facepunch.com/showthread.php?t=1442438&p=49030625&viewfull=1#post49030625[/URL] [/QUOTE] Just to extend this answer with a bit more information, the http system in GMod while isn't totally bad, it isn't the greatest either. The http library can actually take quite a while to initialize, as long as ~30 seconds after InitPostEntity has ran depending on how much load your server is under. This means players profiles / any server related settings would have to be delayed for way too long than what is appropriate. This is only after initial run though (fresh or changelevel), once the server is up and running it's as fast as can be I guess.
[QUOTE=BlackAwps;49463254] That means nothing to me. You could still have your server misconfigured to not allow your Linux server to connect to it. But seeing how you said the error was that it couldn't connect to the ip, it sounds like a firewall/permissions problem on your end. I know the module works fine on CentOS, having helped someone fix an error with it. I can 100% assure you the issue is with you.[/QUOTE] Yep. Had to connect with a different client address as it was using the wrong interface, on top of that sysadmin changed the security groups on the RDS instance (aws stuff) without telling me. For some reason I assumed it was the module because it worked fine when I used the mysql shell client. Nice. :v: Sorry for wasting time.
[QUOTE=Teddi Orange;49463602]Just to extend this answer with a bit more information, the http system in GMod while isn't totally bad, it isn't the greatest either. The http library can actually take quite a while to initialize, as long as ~30 seconds after InitPostEntity has ran depending on how much load your server is under. This means players profiles / any server related settings would have to be delayed for way too long than what is appropriate. This is only after initial run though (fresh or changelevel), once the server is up and running it's as fast as can be I guess.[/QUOTE] I know we're getting a bit off topic here, but could it be beneficial to make a (dll) module which uses cURL or something similar for http data fetching instead of http.Fetch? Not instead of this mysql connector but as a general replacement of the http library in gmod?
[QUOTE=ms333;49464402]I know we're getting a bit off topic here, but could it be beneficial to make a (dll) module which uses cURL or something similar for http data fetching instead of http.Fetch? Not instead of this mysql connector but as a general replacement of the http library in gmod?[/QUOTE] I would love someone to do this, cURL is great and i love it.
[QUOTE=BlackAwps;49463254]Doing that would be terrible, slow, and inefficient. This module allows you to communicate with a mysql server directly, allowing you to fetch and update data directly without a middleman. If you wan't prepared statements, do something like in this post. [url]https://facepunch.com/showthread.php?t=1442438&p=49030625&viewfull=1#post49030625[/url] That means nothing to me. You could still have your server misconfigured to not allow your Linux server to connect to it. But seeing how you said the error was that it couldn't connect to the ip, it sounds like a firewall/permissions problem on your end. I know the module works fine on CentOS, having helped someone fix an error with it. I can 100% assure you the issue is with you. ULX must be using something that the wrapper doesn't support, like Database:wait()[/QUOTE] Okay cool, thanks for the reply.
I'm getting this error: [QUOTE][ERROR] addons/blogs-revamped-1-5/lua/blogs/sv_mysql.lua:100: attempt to index field 'Database' (a boolean value) Query - addons/blogs-revamped-1-5/lua/blogs/sv_mysql.lua:100 unknown - addons/blogs-revamped-1-5/lua/blogs/sv_mysql.lua:118 mysql_init - addons/blogs-revamped-1-5/lua/blogs/sv_mysql.lua:228 unknown - addons/blogs-revamped-1-5/lua/blogs/sv_mysql.lua:237 include - [C]:-1 bLogs_Start - 1599:929 unknown - 1599:934 RunStringEx - [C]:-1 onsuccess - BillyLoad Core:108 unknown - lua/includes/modules/http.lua:64[/QUOTE] There's no connection error from the database. What's happening?
[QUOTE=ms333;49464402]I know we're getting a bit off topic here, but could it be beneficial to make a (dll) module which uses cURL or something similar for http data fetching instead of http.Fetch? Not instead of this mysql connector but as a general replacement of the http library in gmod?[/QUOTE] I'll reply here just to sum it up I guess, but any replies please PM me :). Otherwise this is all relative to mysql vs curl vs http (the latter really being the same) for the sake of making it clear to everyone (the curl module I'll answer below). Keep in mind I'm going to try and explain this in a way that makes more sense to the newbie programmer. In terms of mySQL, no. It's better to be communicating directly through mysql as you get instant feedback + the perks of working in pure mySQL on an 'easier' level. With the middle man (http) you're adding two layers of overhead - lua > (http > php) > mysql. This means not only is the data going to potentially get altered as it passes through each layer - but you need to make sure each endpoint is secure and scalable. For example the data needs to be correctly encoded to pass through HTTP (in a decent manner) and then PHP (presuming this is the language of choice here). For many people the PHP layer is actually where things go very wrong. People don't secure it well (not even a basic password system) and as a result when some sort of leak occurs it blows the whole system open. There are also things that don't translate well from PHP > lua and vice-versa. With tmysql4 (or similar connectors) it's a case of plug the connector into your code, design some sort of wrapper (this I cannot emphasise enough) and away you go. Something that instantly gets turned into mysql-speak [I]and[/I] is adequately protected. With the http case you can't be as flexible when modifying how queries work (aka how scaling comes into play). tmysql4 just happens to be a connector that's amazing at what it does and just happens to be one of the nicer ways I've worked with mysql. I'll leave it there for now as there's a whole myriad of things I could dive deeper in to, but won't as this is the wrong place to do that. ---- Anyhow, in terms of a cURL module the answer is a case of "eh, eeehhh I guess?". At the end of the day the http library does a decent job of what it needs to do - it just has a habit of loading too late for any particular startup systems. If your use case is "I need http and I need it now!" then go for it otherwise it's hard to see the point really. [QUOTE=BillyOnWiiU;49545024]I'm getting this error: There's no connection error from the database. What's happening?[/QUOTE] Without seeing your code, we can't help.
[QUOTE=Teddi Orange;49556990]Without seeing your code, we can't help.[/QUOTE] [CODE]bLogs.MySQL.Database,bLogs.MySQL.Error = tmysql.initialize(Sensitive.IPAddress,Sensitive.Username,Sensitive.Password,Sensitive.Database,Sensitive.Port) if (bLogs.MySQL.Error ~= nil) then bLogs.print("Could not connect to database: " .. bLogs.MySQL.Error,"error") return else bLogs.print("Connected to database successfully!","good") bLogs.print("NOTE: MySQL only does anything when a player is connected.","bad") function bLogs.MySQL.Query(query_text_,callback,raw, ... ) local query_text = "" for _,v in pairs(string.Explode("\n",query_text_)) do query_text = query_text .. string.Trim(v) .. "\n" end query_text = string.sub(query_text,1,-2) if (bLogs.MySQL.Debug == true) then bLogs.print(query_text,"bad") end bLogs.MySQL.Database:Query(query_text,function(results, ... ) if (bLogs.MySQL.Debug == true) then PrintTable(results) end if (results[1].error ~= nil) then bLogs.print("Error with query: " .. results[1].error,"bad") return end if (callback) then if (raw == true) then callback(results, ... ) else callback(results[1].data or {}, ... ) end end end, ... ) end [...][/CODE] It was a customer having problems getting the error. I just couldn't figure out why it was happening. I can't see why the database variable would ever be a boolean unless there's an error, which, apparently.. there isn't :wavey:
[QUOTE=BillyOnWiiU;49558064]I can't see why the database variable would ever be a boolean unless there's an error, which, apparently.. there isn't :wavey:[/QUOTE] I would just ask him to make sure he's using the right module. If the error return is actually a blank string, that means that for some reason the error result isn't working right.. Which is just.. odd.. You should really be checking the database value instead of just the error though. [QUOTE=BillyOnWiiU;49558064][CODE] ... if (not bLogs.MySQL.Database) then bLogs.print("Could not connect to database: " .. bLogs.MySQL.Error,"error") return else ... [/CODE][/QUOTE]
[QUOTE=BlackAwps;49558931]:snip:[/QUOTE] Thanks, I'll do that. Here's the ticket if you'd like to see it. Very weird :v: [t]http://i.imgur.com/KhgH4b7.png[/t]
The tmysql4 crash with last gmod [url]https://github.com/blackawps/gm_tmysql4/issues/2[/url] @edit The addons connected with the wrapper crash the server on last update, tmysql addons is running normally... @edit2 No is crash by last update, but is a bug [url]https://github.com/blackawps/gm_tmysql4/issues/2[/url]
Sorry! literally cant read :(
- author snipped question -
Does anyone still do patches/updates for this?
[QUOTE=Nipah;49626304]Does anyone still do patches/updates for this?[/QUOTE] [url]https://github.com/blackawps/gm_tmysql4[/url]
Sorry if this question sounds dumb... but im coming back to lua after a long break. Just starting toying with tmysql and ran into an issue. Is there any way to have a getter function that runs a query and is able to return the result of that query from that same function. For example: [lua] function getPerson() local person db:Query("SELECT * FROM test_table WHERE name = Bob", function(results) person = results[1] end) return person end [/lua] This does not work because the getPerson function finished before the query finishes. What would be a work around to doing this? [B]Edit:[/B] Nevermind I think it'd be best if I just restructure my code to where I get everything from pure lua and only use sql to update tables in lua when it changes.
[QUOTE=Gaming_Unlim;49947495]Is there any way to have a getter function that runs a query and is able to return the result of that query from that same function. This does not work because the getPerson function finished before the query finishes. What would be a work around to doing this? [/QUOTE] When you run into the situation again, use callbacks. Callbacks are functions passed to other functions that are [I]called back[/I] when something happens. You're already using one on line 4 when you pass the function that receives the results from the query. Your example would become: [lua] function getPerson(callback) db:Query("SELECT * FROM test_table WHERE name = 'Bob'", function(results) callback(results[1]) end) end [/lua] Example usage: [lua] getPerson(function(person) print("Person: ", person) end) [/lua]
Uh.. how install this ?
[QUOTE=AkainuTAMAKI;49957293]Uh.. how install this ?[/QUOTE] step 1. On your server go to the folder garrysmod/lua create a folder called bin there. (Unless it already exists) step 2. Put the file gmsv_tmysql4_win32.dll (assuming you are using windows.) in the bin folder.
"Deadlock found when trying to get lock; try restarting transaction" Does anyone have any idea what could possibly be causing this error? [editline]2nd April 2016[/editline] Nevermind, this isn't a tmysql4 exclusive issue I don't think. Bizarre that it's only begun to happen recently.
[QUOTE=Joeyl10;50055811]"Deadlock found when trying to get lock; try restarting transaction" Does anyone have any idea what could possibly be causing this error? [editline]2nd April 2016[/editline] Nevermind, this isn't a tmysql4 exclusive issue I don't think. Bizarre that it's only begun to happen recently.[/QUOTE] What database engine are you using? (InnoDB vs myISAM / something else)?
I literally couldn't find the "Search in thread" button so I'm already asking you sorry if this question was posted before: can this work with TTT Damagelogs by tommy228? If so, how? I'm having problems with his script like it display on my site only logs of first round of random maps so I realised that maybe it was mysqloo the problem and searched for an alternative.
Is it possible that we could get support for prepared statements? [url]http://dev.mysql.com/doc/refman/5.7/en/c-api-prepared-statements.html[/url]
-snip-
[QUOTE=NightExcessive;50093608]Is it possible that we could get support for prepared statements? [url]http://dev.mysql.com/doc/refman/5.7/en/c-api-prepared-statements.html[/url][/QUOTE] Cant you do it in pure mysql? [url]http://dev.mysql.com/doc/refman/5.7/en/sql-syntax-prepared-statements.html[/url]
[QUOTE=andreblue;50095661]Cant you do it in pure mysql? [url]http://dev.mysql.com/doc/refman/5.7/en/sql-syntax-prepared-statements.html[/url][/QUOTE] A limited version could be implemented without support from the binary module, but it would not be as efficient as using the API. [quote] An alternative SQL interface to prepared statements is available. This interface is not as efficient as using the binary protocol through a prepared statement API, but requires no programming because it is available directly at the SQL level... [/quote]
[QUOTE=Teddi Orange;50059294]What database engine are you using? (InnoDB vs myISAM / something else)?[/QUOTE] Apparently write deadlocks are just an issue with transactions and the solution is literally to just run the query again. It didn't have anything to do with the engine I was running.
What's the purpose of giving an object to db:Query()?
Sorry, you need to Log In to post a reply to this thread.