lua-users home
lua-l archive

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

Well, it looks like we suddenly have an abundance of interfaces to
PostgreSQL ;)  Having a choice is always a good thing.



This lacks licensing information (or I did not find it).

> local res = db:exec("SELECT name FROM persons WHERE id = $1", {id})
> for r in res:rows()
>     print(
> end

A good idea, maybe I "steal" it.

>> You get the idea...  Currently we are trying to make use of PostgreSQL's
>> asynchronous notification feature, linking a notificatin to the
>> execution of a Lua function:
>> db:listen('AN_EVENT', function()
>>    print('Event AN_EVENT was signalled')
>> end)
>> Then when e.g. on a psql prompt you enter 'notify AN_EVENT;', above
>> function would be called.
> my fork of luapgsql:

No license information, either.

> db:exec('LISTEN somenotify')
> -- wait indefinitely for NOTIFY:
> db:notifywait()
> -- OR wait for NOTIFY, up to six seconds
> db:notifywait(6)
> for my needs NOTIFY-wait function is better, but if someone need
> NOTIFY-driven callback - it can be added as well.

To be honest, I left out a small, but important detail:  Our
implementation works in an X11 context only, i.e. we use X11 library
calls internally.