[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: String to use in luasql env:connect()????
- From: Tomas Guisasola Gorham <tomas@...>
- Date: Sun, 16 Jan 2011 10:17:51 -0200 (BRST)
Hi Steve
I'm not sure what you mean by providing a password to psql.
I meant you may had provided a password to psql and forgot to
pass it to envv:connect() as its third argument, but this does not seem
to be the case. Just asking :-)
If I could just get ONE thing to connect, I could exploit the differences and
figure out the variables, but seemingly every single string I put in
envv.connect() comes back with " LuaSQL: Error connecting to database".
I had the same problem (lack of error information) some time ago and changed the code on env_connect (the C implementation). Could you check your implementation? The code I am using is:
static int env_connect (lua_State *L) {
const char *sourcename = luaL_checkstring(L, 2);
PGconn *conn;
getenvironment (L); /* validate environment */
if ((lua_gettop (L) == 2) && (strchr (sourcename, '=') != NULL))
conn = PQconnectdb (sourcename);
else {
const char *username = luaL_optstring(L, 3, NULL);
const char *password = luaL_optstring(L, 4, NULL);
const char *pghost = luaL_optstring(L, 5, NULL);
const char *pgport = luaL_optstring(L, 6, NULL);
conn = PQsetdbLogin(pghost, pgport, NULL, NULL,
sourcename, username, password);
}
if (PQstatus(conn) == CONNECTION_BAD)
return luasql_failmsg(L, "error connecting to database. PostgreSQL: ", PQerrorMessage(conn));
PQsetNoticeProcessor(conn, notice_processor, NULL);
return create_connection(L, 1, conn);
}
I'll tell you one funny thing though, now that you mention it. Work I do in
psql and work I do in pgadmin3 seem to not know about each other. Could that
have something to do with it?
I don't think so...
Regards,
Tomás