Skip to content

Create openresty-odbc-connection.md #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions Connect-with-Exasol/openresty-odbc-connection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Openresty Exasol ODBC connection
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Openresty Exasol ODBC connection
# OpenResty Exasol ODBC connection

Below are steps to connect to Exasol from Openresty.

* Install openresty [Openresty Installation manual](https://openresty.org/en/linux-packages.html#ubuntu)
* install Luarocks

```markup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```markup
```shell

wget https://github.com/luarocks/luarocks/archive/v3.0.0.tar.gz

tar zxvf v3.0.0.tar.gz

./configure --prefix=/usr/local/openresty/luajit/ --with-lua=/usr/local/openresty/luajit/ --lua-suffix=jit --with-lua-include=/usr/local/openresty/luajit/include/luajit-2.1

sudo make build

sudo make install
```

* install ODBC package in luarocks
```markup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```markup
```shell

luarocks install odbc
```

* install Exasol ODBC driver, create DSN for Exasol DB [ODBC Drivers for Linux/FreeBSD | Exasol Documentation](https://docs.exasol.com/db/latest/connect_exasol/drivers/odbc/odbc_linux.htm)

* Execute connection test scripts

**odbctest.sh**
```markup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```markup
```shell

# set -x
# ORHOME is the path to the OpenResty install
export ORHOME="/usr/local/openresty"
export ODBCINI="${ORHOME}/odbc/.odbc.ini"
export LD_LIBRARY_PATH="${ORHOME}/luajit/lib"
export PATH="$PATH:${ORHOME}/bin/"
resty odbctest.lua $1
echo "Retun code from resty $?"
```
**odbctest.lua**
```markup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```markup
```lua

local odbc = require("odbc")
local call = [[select * from sys.exa_all_tables]]
print("Using dsn " .. arg[1])
local DSN = arg[1]
print("About to connect")
local cnn,err = odbc.connect(DSN)
if cnn == nil then
print("Failed to connect" .. err.message)
else
print("Connected")
end
local stmt,err = cnn:statement()
if stmt == nil then
print("Failed to prepare Statement" ..err.message)
else
print("Prepared statement" )
end
local ret,err = stmt:execute(call)
if ret == nil then
print("Failed to execute statement" .. err.message)
else
print("Executed satement")
end
local cols = ret:colnames()
if string.upper(cols[1]) == [[ERR]] then
-- There has been some sort of error
print("Some sort of error was raised " .. ret:fetch())
end
```