Changeset - dedda212b5ff
[Not reviewed]
0 1 1
Mark Raasveldt - 9 years ago 2016-08-12 15:55:18
mark.raasveldt@gmail.com
Add odbc driver and labnotes.
2 files changed with 164 insertions and 2 deletions:
0 comments (0 inline, 0 general)
ODBCSetup.labnotes
Show inline comments
 
new file 100644
 
-- MonetDB --
 

	
 
Install ODBC client: sudo apt-get install libmonetdb-client-odbc (or --enable-odbc)
 

	
 
odbcinst.ini
 

	
 
[MonetDB]
 
Description     = MonetDB Driver
 
Driver          = /usr/lib/libMonetODBC.so
 
Setup           = /usr/lib/libMonetODBCs.so
 

	
 
odbcinst -i -d -f odbcinst.ini
 

	
 
odbc.ini
 

	
 
[MonetDB]
 
Description         = Connection for MonetDB
 
Driver              = MonetDB
 
Database            = database
 
Servername          = localhost
 
User	            = monetdb
 
Password            = monetdb
 
Port                = 50000
 

	
 
odbcinst -i -s -f odbc.ini
 

	
 
isql MonetDB
 

	
 

	
 
-- Postgres --
 
sudo apt-get install odbc-postgresql
 

	
 
odbcinst.ini
 

	
 
[PostgreSQL]
 
Description     = PostgreSQL Driver
 
Driver          = /usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so
 
Setup           = /usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so
 

	
 
odbc.ini
 

	
 
[PostgreSQL]
 
Description         = Connection for PostgreSQL
 
Driver              = PostgreSQL
 
Database            = user
 
Servername          = localhost
 
User	            = user
 
Password            = user
 
Port                = 5432
 

	
 

	
 
-- MySQL --
 
MySQL ODBC Connector: https://dev.mysql.com/downloads/connector/odbc/2.50.html
 

	
 

	
 
odbcinst.ini
 

	
 
[MySQL]
 
Description     = MySQL Driver
 
Driver          = /home/user/odbc/mysql-odbc/lib/libmyodbc5a.so
 
Setup           = /home/user/odbc/mysql-odbc/lib/libmyodbc5S.so
 

	
 
odbc.ini
 

	
 
[MySQL]
 
Driver              = MySQL
 
Description         = Connection for MySQL
 
Database            = user
 
Server              = 127.0.0.1
 
User                = user
 
Uid                 = user
 
Password            =
 
Port                = 3306
 

	
 

	
 

	
 
-- DB2 --
 
{{sqllib/cfg/db2cli.ini}}
 
[DB2_SAMPLE]
 
Database = DB
 
Protocol=TCPIP
 
Port=50000
 
Hostname=localhost
 
UID=user
 
PWD=user
 

	
 
odbcinst.ini
 

	
 
[DB2]
 
Description             = IBM DB2 Adapter
 
Driver                  = /home/user/sqllib/lib/libdb2.so
 
FileUsage               = 1
 
DontDLClose             = 1
 

	
 
odbc.ini
 

	
 
[DB2_SAMPLE]
 
Description     = Connection for DB2
 
Driver      	= DB2
 

	
 
export DB2INSTANCE=user
 
isql DB2_SAMPLE -d, user user
 

	
 
-- Oracle -- 
 

	
 
export ORACLE_SID=XE
 
export TWO_TASK=$ORACLE_SID
 
export TNS_ADMIN=/home/user/odbc/tnsnames.ora
 
export ORACLE_BASE=/usr/lib/oracle
 
export ORACLE_HOME=/usr/lib/oracle/12.1/client64
 

	
 
-- tnsnames.ora -- (HAS TO BE IN: $ORACLE_HOME/network/admin/tnsnames.ora)
 
XE2 =
 
     (DESCRIPTION =
 
     (ADDRESS= (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT=49161))
 
     (CONNECT_DATA =
 
     (SERVER = DEDICATED)
 
     (SERVICE_NAME = XE)
 
     )
 
)
 

	
 

	
 
[Oracle]
 
Description     = Oracle ODBC driver for Oracle 12c
 
Driver          = /usr/lib/oracle/12.1/client64/lib/libsqora.so.12.1
 
Setup           = /usr/lib/x86_64-linux-gnu/odbc/liboraodbcS.so
 
FileUsage       =
 
CPTimeout       =
 
CPReuse         =
 

	
 
[Oracle]
 
Application Attributes = T
 
Attributes = W
 
BatchAutocommitMode = IfAllSuccessful
 
CloseCursor = F
 
DisableDPM = F
 
DisableMTS = T
 
Driver = Oracle
 
EXECSchemaOpt =
 
EXECSyntax = T
 
Failover = T
 
FailoverDelay = 10
 
FailoverRetryCount = 10
 
FetchBufferSize = 64000
 
ForceWCHAR = F
 
Lobs = T
 
Longs = T
 
MetadataIdDefault = F
 
QueryTimeout = T
 
ResultSets = T
 
ServerName = //127.0.0.1:49161/XE
 
SQLGetData extensions = F
 
Translation DLL =
 
Translation Option = 0
 
User = system
 
Uid = system
 
UserID = system
 
Password = oracle
 

	
 
sudo odbcinst -i -d -f odbcinst.ini && odbcinst -i -s -f odbc.ini
 

	
 
echo "SELECT * FROM lineitem LIMIT 100" | isql MySQL -d, > /dev/null
 

	
pmodbc.c
Show inline comments
 
@@ -7,6 +7,7 @@
 
#include <assert.h>
 

	
 
// compilation: gcc -g pmodbc.c -lodbc -o pmodbc
 
// opt: gcc -O3 pmodbc.c -lodbc -o pmodbc
 

	
 
static void list_drivers();
 
static void query_db(char* dsn, char* query, int csv);
 
@@ -105,8 +106,6 @@ static void query_db(char* dsn_str, char* query, int csv) {
 
            puts(csvbuf);
 
        }
 
    }
 
    extract_error("SQLStmt for dbc", stmt, SQL_HANDLE_STMT);
 
    exit(1);
 
}
 

	
 
void extract_error(char *fn, SQLHANDLE handle, SQLSMALLINT type)
0 comments (0 inline, 0 general)