[solved]Need enlightenment with MYSQL in plugins

Discussion in 'Spigot Plugin Development' started by bsy6766, Jun 9, 2015.

  1. Hey guys, I have some question with using mysql in plugin.

    I recently got request from someone to support mysql on my plugin, but wasn't sure the point of using mysql. (have some mid-sized text based data. 3 columns, 1000 lines).
    So why do people use mysql? Is there any good reason to use it other than just storing data?
    And speaking of storing data, what's the advantages of storing data with mysql compared to some files like yml?

    Any information or example of usage will be appeciated.

    Oh and I know very little about sql, have a bit experience with postgres but wonder if that helps any...
    #1 bsy6766, Jun 9, 2015
    Last edited: Jun 10, 2015
  2. Something SQL can be really good at is storing data that other things can hook into. Say you wanted to keep kill counts for your server but you also want your website to display these kill counts, what you can do is have your website configured to look into the SQL DB and find the kill counts. It can effectively help hook your server with your website.

    Another advantage if you don't have a lot of room on your server machine you can store large amounts of data on another server.

    You can easily update values. Like if you had that kill count. If you used yaml you'd have to find the player, get their kills, add a kill, then write the data. With SQL you can send an async UPDATE statement that basically says 'add one to this'.

    There's a lot of nice pretty GUIs you can use to help look at your data

    Bonus Round:
    OH! And in YAML if a result doesn't exist it can be hard to find out (Like it could be 0 (int) or "" ( String) or null (Objects) where as in SQL it will throw an exception (I like this because I can make a few typos in YAML and take a while to nail down why people always seem to have 0 kills, where as if I did this in SQL I'd know that I had spelt something wrong)

    Bonus Round x2:
    If you want to... say get all users with 60 kills, in YAML there's no easy way to do this. (Load everyone up, and loop through it all checking?) where in SQL you can use a SELECT WHERE query and it will return everyone who matches the criteria)
  3. Oh I see...hooking on website and querying data...
    • Like Like x 1