lua-users home
lua-l archive

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


On 9/1/11, Terry Bayne <trbayne@gmail.com> wrote:
> On Thu, Sep 1, 2011 at 12:29, joao lobato <btnfdp.lobato@gmail.com> wrote:
>
>> Hi, list
>>
>> I'be been trying to use LuaSQL to connect to a PostgreSQL database,
>> unsuccessfully.
>>
>> I'm using Lua for Windows and when I try
>>
>>  require 'luasql.postgres'
>>
>> I get the usual require error about it not being able to find the module.
>>
>> I checked the searched directories and there's no postgres.dll (only
>> mysql.dll, odbc.dll and sqlite3.dll).
>>
>> I could use some assistance regarding:
>>  - am I missing something? (besides the dll... ;) )
>>  - how do I connect to the db using ODBC if that is the only option?
>>  - what would I have to do to compile the dll myself in a way that is
>> compatible with LfW?
>>  - is there an alternative to LuaSQL that I'm overlooking?
>>
>>
> To use ODBC you have to setup an ODBC Data Source to the database.   Under
> windows 7 this is accomplished from the Start Menu/Control
> Panel/Administrative Tools/Data Sources
>
> This page gives some details on what you need to do:
>
>
> http://wiki.postgresql.org/wiki/Using_Microsoft_.NET_with_the_PostgreSQL_Database_Server_via_ODBC
>
> And this page hosts the official postgressSQL ODBC Driver:
>
>     http://pgfoundry.org/projects/psqlodbc
>
> Hope that helps.
>
> Terry
>

Thanks

I followed your instructions and those in your link and I managed to
get it to connect using ODBC.

However, this simple test:

  require 'luasql.odbc'
  e = luasql.odbc()
  c = e:connect 'PostgreSQLtest'
  r = c:execute 'select * from foo'

gets a

  Assertion failed!
  Program: C:\Program Files\Lua\5.1\lua.exe
  File: src\ls_odbc.c
  Line 163

when it tries to execute the statement :(