[Kepler-Project] LuaSQL Usage
Bertrand Mansion
golgote at mamasam.com
Mon May 14 05:44:49 BRT 2007
Sorry for posting one after the other, maybe I should post that
somewhere else ?
Here is a version for PostgreSQL:
static int conn_quote(lua_State *L)
{
const char *unquoted = luaL_checkstring(L, 2);
size_t unquotedlen = strlen(unquoted);
size_t quotedlen;
char *quoted = malloc(2 * unquotedlen + 3);
quotedlen = PQescapeString(quoted + 1, unquoted, unquotedlen);
quoted[0] = quoted[++quotedlen] = '\'';
quoted[++quotedlen] = '\0';
lua_pushstring(L, quoted);
free(quoted);
return 1;
}
It's untested, I haven't PGSQL at my disposal here.
--
Bertrand Mansion
Mamasam
Work : http://www.mamasam.com
Blog : http://golgote.freeflux.net
More information about the Kepler-Project
mailing list