[PD] Pd and SQL
Jack via Pd-list
pd-list at lists.iem.at
Sun Jul 13 12:11:15 CEST 2014
Hello,
Pdlua is working fine on my system.
I installed :
$ sudo apt-get install lua-sql-sqlite3-dev
and used the code below to create a file 'mysql.pd_lua'.
But when i tried to create [mysql] object in Pd, i got in the pd console :
maximum object loading depth 1000 reached
mysql
... couldn't create
Did I miss something ?
++
Jack
Le 23/06/2014 21:05, patrice colet via Pd-list a écrit :
> it still works if luasql.sqlite is replaced by luasql.sqlite3 like
> following lsql.pd_lua code:
>
> :)
>
> -- SQL example for pdlua
> -- Written by Frank Barknecht in 2007, use however you like.
>
> -- load driver
> require "luasql.sqlite3"
>
> local M = pd.Class:new():register("lsql")
>
> function M:initialize(name)
> -- create environment object
> self.env = assert (luasql.sqlite3())
> self.con = nil
> self.outlets = 2
> self.inlets = 1
> return true
> end
>
>
> function M:in_1_open(atoms)
> -- connect to data source
> self.con = assert (self.env:connect(atoms[1]))
> end
>
>
> function M:in_1_sql(atoms)
> if not self.con then
> self:error("open a database file first")
> return
> end
> local command = table.concat(atoms, " ")
> -- use : instead of ,
> command = command:gsub(":", ",")
> local cur = assert (self.con:execute(command))
> if type(cur) == "number" then
> -- report affected rows to second outlet:
> self:outlet(2, "float", {cur})
> else
> local row = cur:fetch({})
> while row do
> self:outlet(1, "list", row)
> row = cur:fetch(row)
> end
> -- close cursor
> cur:close()
> end
> end
>
>
>
>
>
> Le 19/06/2014 15:37, Frank Barknecht via Pd-list a écrit :
>> Hi,
>>
>> is it already 7 years ago? Anyway, in 2007 I posted an example using
>> luaSQL and Pdlua
>> that should still work:
>> http://lists.puredata.info/pipermail/pd-dev/2007-11/009964.html
>>
>> Ciao
>
>
> _______________________________________________
> Pd-list at lists.iem.at mailing list
> UNSUBSCRIBE and account-management ->
> http://lists.puredata.info/listinfo/pd-list
More information about the Pd-list
mailing list