-
Notifications
You must be signed in to change notification settings - Fork 18
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can look at suggestions, add "Background" and "Additional References" sections, and footer, as per "Tutorial" template, so that we could finally merge this one? :)
Update openresty-odbc-connection.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
I added a couple more cosmetic suggestions.
You can decide if you want to incorporate them, then merge.
Below are steps to connect to Exasol from Openresty. | ||
|
||
* Install openresty [Openresty Installation manual](https://openresty.org/en/linux-packages.html#ubuntu) | ||
* install Luarocks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* install Luarocks | |
* Install LuaRocks |
sudo make install | ||
``` | ||
|
||
* install ODBC package in luarocks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* install ODBC package in luarocks | |
* Install ODBC package in LuaRocks |
```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 | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
```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 | |
``` | |
```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 | |
``` |
```shell | ||
luarocks install odbc | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
```shell | |
luarocks install odbc | |
``` | |
```shell | |
luarocks install odbc | |
``` |
```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 $?" | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
```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 $?" | |
``` | |
```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 $?" | |
``` |
```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 | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
```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 | |
``` | |
```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 | |
``` |
No description provided.