Last Updated: February 25, 2016
·
856
· ejstembler

Connect to Netezza via ODBC in Lua

https://gist.github.com/4420315

-- Connect to Netezza via ODBC from Lua

-- load driver
require "luasql.odbc"

-- create environment object
env = assert(luasql.odbc())

-- connect to data source using an existing DSN
-- assumes username/password are defined with DSN
con = assert(env:connect("NZSQL"))

query = "select count(*) from mytable"

cur = assert(con:execute(query))

count = cur:fetch()
print(string.format("count: %d", count))

-- close everything
cur:close()
con:close()
env:close()