Skip to content

Commit

Permalink
initial import of luapgsql
Browse files Browse the repository at this point in the history
  • Loading branch information
mbalmer committed Apr 5, 2012
0 parents commit c4a39bf
Show file tree
Hide file tree
Showing 8 changed files with 720 additions and 0 deletions.
18 changes: 18 additions & 0 deletions GNUmakefile
@@ -0,0 +1,18 @@
SRCS= luapgsql.c
LIB= pgsql

CFLAGS+= -O3 -Wall -fPIC -I/usr/include -I/usr/include/lua5.1 \
-I/usr/include/postgresql
LDADD+= -L/usr/lib

LIBDIR= /usr/local/share/lua/5.1

${LIB}.so: ${SRCS:.c=.o}
cc -shared -o ${LIB}.so ${CFLAGS} ${SRCS:.c=.o} ${LDADD}

clean:
rm -f *.o *.so
install:
install -d ${LIBDIR}
install ${LIB}.so ${LIBDIR}

25 changes: 25 additions & 0 deletions Makefile
@@ -0,0 +1,25 @@
SRCS= luapgsql.c
LIB= pgsql

OS!= uname

.if ${OS} == "NetBSD"
LOCALBASE= /usr/pkg
LDADD+= -R/usr/lib -R${XDIR}/lib -R${LOCALBASE}/lib
.else
LOCALBASE= /usr/local
.endif

NOLINT= 1
CFLAGS+= -I${LOCALBASE}/include
LDADD+= -L${LOCALBASE}/lib -lpq

LIBDIR= ${LOCALBASE}/lib/lua/5.1

libinstall:

install:
${INSTALL} -d ${DESTDIR}${LIBDIR}
${INSTALL} lib${LIB}.so ${DESTDIR}${LIBDIR}/${LIB}.so

.include <bsd.lib.mk>
7 changes: 7 additions & 0 deletions README
@@ -0,0 +1,7 @@
A Lua Binding for PostgreSQL

Copyright (C) Micro Systems Marc Balmer.
You can reach the author at marc@msys.ch

Makefile is for BSD systems
GNUmakefile is for Linux systems
12 changes: 12 additions & 0 deletions error.lua
@@ -0,0 +1,12 @@
require 'pgsql'

conn = pgsql.connectdb('dbname=arcapos user=lua password=lua2011!')

print("errorMessage: " .. conn:errorMessage())
conn:exec("this will not work")
print("errorMessage: " .. conn:errorMessage())
conn:exec("select now()")
print("errorMessage: " .. conn:errorMessage())

conn:finish()

0 comments on commit c4a39bf

Please sign in to comment.