lua-users home
lua-l archive

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


On 15 January 2011 21:32, Steve Litt <slitt@troubleshooters.com> wrote:
> On Saturday 15 January 2011 15:53:26 Ed wrote:
>
>> my fork of luapgsql:
>> https://github.com/edo1/luapgsql
>>
>> 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.
>
> Hi Ed,
>
> I'm not even to the point where I can choose between db:exec() or the higher
> level stuff. Look what happens to me with this little program:
>
> #!/usr/bin/lua
> require "luasql.postgres"
> envv = assert (luasql.postgres())
> con = assert (envv:connect("testlua", "slitt", nil))
>
> The preceding program produces the following output:
>
> slitt@mydesk:~$ ./littfails.lua
> /usr/bin/lua: ./littfails.lua:4: LuaSQL: Error connecting to database.
> stack traceback:
>        [C]: in function 'assert'
>        ./littfails.lua:4: in main chunk
>        [C]: ?
> slitt@mydesk:~$
>

> Anyway, database testlua was one I had just created within psql and I didn't
> give it a password. So I'm confused why LuaSQL.postgres's connect() command
> fails. I spent a couple hours putting in various combinations of stuff as its
> arguments, did a bunch of googling, and absolutely nothing changed the
> symptom. I'm beginning to think there's a basic fact that I'm missing.
>

When you say you didn't give it a password, what do you mean? When I
have issues with Postgres it's usually permissions. In particular
databases don't have passwords, user accounts have passwords.

Try setting up a user account with a password in postgres, and then
connect with envv:connect("testlua", "username", "password",
"localhost"). Check that you can connect to and query the DB with:
psql --user username --host localhost

Regards,
Matthew