Skip to content

Instantly share code, notes, and snippets.

@ederrafo
Last active May 6, 2022 08:25
Show Gist options
  • Save ederrafo/8efd3ca7935c25d824cbb4df637a2b08 to your computer and use it in GitHub Desktop.
Save ederrafo/8efd3ca7935c25d824cbb4df637a2b08 to your computer and use it in GitHub Desktop.
odbc

The system file odbcinst.ini contains information about ODBC drivers available to all users ** Manual Instalation: ** If make clean give error

$ sudo apt-get install libtool autoconf && autoreconf -f -i

If Make no exist

 $ sudo apt-get install make

Continue

$ wget http://www.unixodbc.org/unixODBC-2.3.4.tar.gz
$ tar -xzf unixODBC-2.3.4.tar.gz && cd unixODBC-2.3.4

Configuring and Compiling the Source :

Option 1:

  $ ./configure --prefix=/opt/odbc/unixodbc --exec-prefix=/opt/odbc/unixodbc/oth --bindir=/opt/odbc/unixodbc/bin 
    --sbindir=/opt/odbc/unixodbc/sbin 
    --libexecdir=/opt/odbc/unixodbc/libexec 
    --sysconfdir=/opt/odbc/unixodbc/etc 
    --libdir=/opt/odbc/unixodbc/lib 
    --includedir=/lib 
    --includedir=/lib64 && make && sudo make install 

Option 2:

$ ./configure --prefix=/usr 
   --sysconfdir=/etc 
   --libdir=/lib 
   --includedir=/lib 
   --includedir=/lib64 
   --sbindir=/sbin
   --bindir=/bin && make && sudo make install 

Option 3:

$ ./configure --prefix=/usr 
    --sysconfdir=/etc 
    --libdir=/lib/x86_64-linux-gnu/ 
    --includedir=/lib/x86_64-linux-gnu/ 
    --includedir=/lib64 
    --sbindir=/sbin 
    --bindir=/bin && make && sudo make install
  • If we are testing php odbc with apache web server, restart Apache.
  • Enable debugging unixodbc
  • Check version of unixODBC*
$ isql --version
  • Trace
  $ sudo nano /etc/odbcinst.ini
  > [ODBC]
  > Trace=Yes
  > TraceFile=/tmp/unixodbc.log

Automatic Instalation

In Debian

  $ sudo apt-get unixodbc unixodbc-dev

** Commad ODBCINST ** Find where those files are:

  $ odbcinst -j
    unixODBC 2.3.1
    DRIVERS............: /etc/odbcinst.ini
    SYSTEM DATA SOURCES: /etc/odbc.ini
    FILE DATA SOURCES..: /etc/ODBCDataSources
    USER DATA SOURCES..: /home/usuario/.odbc.ini
    SQLULEN Size.......: 8
    SQLLEN Size........: 8
    SQLSETPOSIROW Size.: 8

You should check that your ODBC driver is loadable:

$ ldd /usr/dlc/odbc/lib/pgoe1023.so
$ nano /etc/odbcinst.ini
[ODBC]
Trace = yes
TraceFile = /tmp/unixodbc.log

[FreeTDS]
Description = FreeTDS
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
  $ nano /etc/odbc.ini
  [TS]
  Description = "test"
  Driver = FreeTDS
  Server = SERVER
  Port = 1433
  Database = DBNAME
  $ cat /etc/odbc.ini
  $ cat /etc/odbcinst.ini

Show available ODBC drivers

$ odbcinst -q -d
  [TDSDRIVER]

Show available ODBC sources

$ odbcinst -q -s
  [MSSQL]
  [SQL01]

  1. First install libraries necessary
  $ apt-get install php7.0-odbc php7.0-xml
  $ apt-get install tdsodbc
  $ apt-get install unixodbc
  $ apt-get install freetds-bin
  1. Second edit these files:
$ nano /etc/odbcinst.ini
  [FreeTDS]
  Description = FreeTDS
  Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
  $ nano /etc/odbc.ini
  [xxxxxxxxx]
  Driver = FreeTDS
  Description="Test odbc"
  Server=xx.xx.x.xx
  Port=2638
  TDS Version= 5.0
  Database=tudatabase

  [XxxxxxxXxxxxx]
  Driver=FreeTDS
  Description=Document
  Trace=No
  Server=xx.x.x.xx
  Port=1117
  TDS Version=5.0
  Database=tudatabase
  $ isql -v DNS user pwd
  SQL> quit
  $ tsql -S DNS -U user -P pwd

srcs: http://www.bictor.com/2014/05/13/configure-unixodbc-for-ubuntu-14-04-using-freetds/ http://help.interfaceware.com/kb/904 http://prog3.com/sbdm/blog/ysynhtt/article/details/45322741 DBVisualizer Free 9.2.15 es un IDE para realizar consultar a diversas BD entre ellas Sybase y SQLServer http://www.linuxfromscratch.org/blfs/view/svn/general/unixodbc.html https://phpgrid.uservoice.com/knowledgebase/articles/224070-warning-odbc-connect-function-odbc-connect-s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment