Jump to content

MySQL as a single resource?


Recommended Posts

Posted

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!

Posted (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 by Sorata_Kanda
Posted
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.

  • Discord Moderators
Posted

"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.

Posted

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

Posted (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 by LilDawage
Posted
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 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...