Storing Inventory to SQLite?

Discussion in 'Plugin Development' started by The_Nesko, Mar 26, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    The_Nesko

    Hi so i'm completely new to sql i just learned the basic of creating tables and saving data on them and i'm trying to store a Inventory in a table as Blob but i get error that i can't cast Inventory to Blob so is there any other way to store Inventory in the table as a field?
     
  2. Offline

    Konato_K

    @The_Nesko Serializing it as a string probably (or anything else, is Blob really a data type?)

    Why do you need SQLite for this?
     
  3. Offline

    mythbusterma

    @Konato_K

    BLOB is indeed a data type, it's an abbreviation of "Binary Large OBject," and can refer to any generic binary data you want to store in the database.


    @The_Nesko

    Why would you use SQL and not a .yml file? You're not going across servers if you're using SQLite (or, at least, I really hope you aren't). So to what end are you doing this?

    You can't just go casting types around like that and expect them to work. You have to serialise them yourself. I would recommend turning it into some sort of string.
     
  4. Offline

    The_Nesko

    @Konato_K @mythbusterma
    Yeah serializing seems to do the trick thanks. :)
    And the reason why i'm using SQLite is because i'm storing large amounts of information and it would be too messy if i did it with .yml file, plus i want to learn SQL.
     
  5. Offline

    mythbusterma

    @The_Nesko

    You're going to have better luck with .yml, and it will be user editable.
     
  6. Offline

    Kilorbine

    And you have to know SQlite is really(I mean... REALLY) taking a lot of time to execute.
    It could really slow your server
     
  7. Offline

    Konato_K

    @Kilorbine SQLite is pretty fast since it's a local storage system and it reads from disk, unlike MySQL or other SQL database servers.

    I didn't know Blob was an actual Java class, I always thought it only existed in SQL
     
  8. Offline

    The_Nesko

    @mythbusterma Well the ting is the stuff that needs to be editable will be in yml but the stuff i'm saving in the sql should't because it can easily break the plugin if they edit some part of information.
     
  9. Offline

    Konato_K

    @The_Nesko You can also edit a sql database (delete it, open it with a text editor and modify it, eat it), if you have write access to the directory, it doesn't matter if it's a database or a flat file, it can be broken
     
  10. Offline

    mythbusterma

    @The_Nesko

    Why would it break if someone for example changed a stack of cobble to a stack of stone?
     
  11. Offline

    mcdorli

    Save it to a bit file.
     
  12. Offline

    The_Nesko

    @mythbusterma Well that would not break the plugin but it would make it work different form the way it supposed to work. And i'm saving a lot more stuff in sql besides Inventory.
     
Thread Status:
Not open for further replies.

Share This Page