Sorata_Kanda Posted October 6, 2018 Share Posted October 6, 2018 Hey everyone, as the title might tell you, I'm wondering what's more efficient: Having a single MySQL resource handling all the MySQL work and have something like a MySQL script in each of my scripts where I need it? At the moment, I use a single MySQL resource which manages all the MySQL stuff, but I'm not sure if that's the right way or not. It manages really everything related to MySQL where required: admin system, ticket system, etc. What's your opinion on that? Thanks in advance! Link to comment
Dimos7 Posted October 7, 2018 Share Posted October 7, 2018 I use one resource for mysql but i don't use mysql module i use db functions Link to comment
LyricalMM Posted October 7, 2018 Share Posted October 7, 2018 that's better for roleplay gamemodes with many scripts, because you can just use export functions for each file, but I agree with @Dimos7 to use db functions, easier to use Link to comment
Sorata_Kanda Posted October 7, 2018 Author Share Posted October 7, 2018 (edited) I do use the db functions too, but I'm sort of worried that my meta.xml turns to a mess due to the amount of functions I export. Edited October 7, 2018 by Sorata_Kanda Link to comment
AJXB Posted October 7, 2018 Share Posted October 7, 2018 2 hours ago, Sorata_Kanda said: I do use the db functions too, but I'm sort of worried that my meta.xml turns to a mess due to the amount of functions I export. The healthy thing to do is to make one resource and just export the functions. Otherwise, you're just repeating code and that's useless. Link to comment
Discord Moderators Pirulax Posted October 9, 2018 Discord Moderators Share Posted October 9, 2018 "Healthy thing" Sure, exports are the fastest thing on earth, even faster than a Lamborghini without an engine. So, back on topic, they're slow af, so avoid using them if possible. Use db* functions instead whenever possible, and in case of dbPoll, please don't use -1, just give a callback function to dbQuery instead. Link to comment
Sorata_Kanda Posted October 12, 2018 Author Share Posted October 12, 2018 I do use db* function, but the point of putting everything in one resource is not to create multiple database connections throughout multiple resources. Therefore you have one single resource handling MySQL stuff. But I didn't really notice any performance impact when using exported function. Also, why should I use a callback function instead of a -1? @Pirulax Link to comment
LilDawage Posted October 12, 2018 Share Posted October 12, 2018 (edited) yeh Create one File : like getMyDatainfo () return Create table info about you database host name and pass ... Enable Exports info in meta ( getMyDatainfo) exports info database to all resources db = dbConnect( "mysql","dbname="..exports["file name"]:getMyDatainfo () [Colum].." ....................and same for others Edited October 12, 2018 by LilDawage Link to comment
Dimos7 Posted October 12, 2018 Share Posted October 12, 2018 56 minutes ago, Sorata_Kanda said: I do use db* function, but the point of putting everything in one resource is not to create multiple database connections throughout multiple resources. Therefore you have one single resource handling MySQL stuff. But I didn't really notice any performance impact when using exported function. Also, why should I use a callback function instead of a -1? @Pirulax Because the server will froze till get answer from database so it better use callbacks Link to comment
VenomOG Posted October 13, 2018 Share Posted October 13, 2018 SQLite will be better, sms me if you need help making a table with SQLite Link to comment
ShayF2 Posted October 13, 2018 Share Posted October 13, 2018 You can use and improve my SQL Framework and run functions as exports.https://github.com/shaiof/Core-Loader/blob/master/core/sql_s.lua Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now