Saving Table values into an SQL table

So I have come across the need to save a table value(e.g local mytable = {}) into an SQL table. I was curious if this is possible and if it is what data type do I assign to the column that will store this table? My concern is that this defeats the purpose of using SQL but I need to save an unknown number of items which tables inside lua make that very easy to do and SQL not so much. But I need to save these values in a database.

-Thank you

glon.Encode and Decode. Save the encoded value as a string.

You can use glon although i just turn my table into a string with sperators between each item and then Format it when i call it.

I prefer Json to save/load data.

I’m pretty sure there’s a tutorial on the wiki to help you out.

[editline]13th August 2011[/editline]

Yeah, there is.

It seems like it would work all three ways but is there any one way that is faster or more reliable? Or is it just all preference?

(Aside from being human readable which I really don’t need)

You can try all 3 and find which one you like more.

Alternatively, don’t even use a table, query directly from the SQL. Later on this could become a problem, so what I personally would do is in the first file to load(server sided, so init.lua I believe), query the SQL and some how explode the found information into a table(I use the term explode because it is fancy) and just save directly to the SQL so you can cut back on SQL queries. You will have to check and make sure the information in the local table is the same as the information in the SQL Database though.