AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   mysql & sqlite combined (https://forums.alliedmods.net/showthread.php?t=132933)

Jack86 07-20-2010 08:13

mysql & sqlite combined
 
I have a problem with two plugins, first one is cheaterSuspect and second one in simple sql ban logger. The ban logs into mysql db on website and cheatersuspects uses sqlite. Now when both module are loaded only one of these plugins works, didnt tested it thoroughly but it looks like it depends on module or plugin load order. Now the simplest solution is to setup cheatersuspect to uses external db and only mysql module but that for some unknown reason to me causes lag spikes on my server which are repeating every 20 sec, they stop when cheatersuspect is disabled. So what i would like is to somehow force ban logger to uses mysql module and cheatersuspect to uses sqlite module, how can i do this ?

Jack86 07-21-2010 12:02

Re: mysql & sqlite combined
 
Can i do something with SQL_SetAffinity command, there arent many stuff about it, i found it mentioned only in 3 threads here, and should i use SQL_SetAffinity("mysql") or SQL_SetAffinity ("sqlx") for plugin that connects to external db ?

Sylwester 07-22-2010 04:03

Re: mysql & sqlite combined
 
I think it's SQL_SetAffinity("mysql") for mysql and SQL_SetAffinity("sqlite") for sqlite.
If you get lag spikes then maybe your plugin is not using threaded queries.

Jack86 07-22-2010 04:25

Re: mysql & sqlite combined
 
Threaded queries ? cheatersuspect is written with dbi include :P, and i dont feel like rewriting it, and anyway lag ocurred all the time, not just at execution of commands. I did managed it to work, i found out that plugins use modules by their load order (plugin load order is irrelevant) so all plugins will use first module if not otherwise set by SetAffinity. I used SetAffinity in plugin_init, and i wondered can i use it multiple times through plugin to switch at which db query will be executed, something like

SQL_SetAffinity("mysql")
SQL_Execute(Query)
SQL_SetAffinity("sqlite")

Sylwester 07-22-2010 04:59

Re: mysql & sqlite combined
 
http://www.amxmodx.org/funcwiki.php?go=func&id=1113
Quote:

Originally Posted by Notes
Note, that using this while you have open handles to another database type will cause problems. I.e., you cannot open a handle, switch affinity, then close the handle with a different driver.

So, basically you can use it multiple times, but you can't execute query for mysql if you prepared it for sqlite. You should try to avoid using sqlite and mysql in the same plugin.

Jack86 07-22-2010 06:36

Re: mysql & sqlite combined
 
Ok tnx, i'll use some workaround ,set cheatersuspect to log its bans to a file and then mysql ban logger to read that file and write to db.


All times are GMT -4. The time now is 07:08.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.