lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Thanks for the info. I was looking at the DBI google project page. In the examples it still seems you use some SQL to do operations. My aim for example is something like this:x =

tableDB.open('myDB')

x.key1 = {a= "hello world", b=12}

x.y = 23

x.qwerty = true

NOTE: Here myDB is a database with a defined structure (defined by calling the createDB function by passing it a template table previously) having a table with columns key1 (table) and y (number) and another table with columns a (string),b (number)


Now doing x:save() saves the table x into the database and so it is possible to do this:

y = tableDB.open('myDB')
print(y.key1)   -- table: 0001234
print(y.y) -- 23
print(y.key1.a)  -- "hello world"
print(y.qwerty) -- true    (even though not originally defined in the DB structure still it preserves the value)

is it possible to use DBI the same way?

Another thing is that when accessing the values only the relevant values from the database are read and cached and the whole table does not need to be present in the memory for accessing the table.

Thanks,
Milind



On Fri, Jan 31, 2014 at 7:42 AM, Aaron B. <aaron@zadzmo.org> wrote:
On Fri, 31 Jan 2014 06:49:56 -0800
Milind Gupta <milind.gupta@gmail.com> wrote:

> Hi,
>       I have started work on a small module to map lua tables directly to
> sqlite database using luasql. The aim is that if you are using lua tables
> to store all your data then that is all you do. You use them like normal
> lua tables and in the end just do a save command and the changes get saved
> to a database.

I have built exactly this on top of LuaDBI. It's been used in a fair
number of projects and seems to be mature.

Releasing it in LuaRocks has been on my todo list for quite some time
now, just haven't found a moment...

--
Aaron B. <aaron@zadzmo.org>