EiffelStore ODBC with PostgreSQL

The following steps describe how to check the EiffelStudio installation and the required dependencies to use EiffelStore ODBC with PostgreSQL. The steps are also useful for other databases such as MySQL (for which you will to install the MySQL ODBC driver).

Note: For this documentation, tests used Ubuntu 18.04 64 bits and EiffelStudio 18.07 64 bits / Debian 9 and EiffelStudio 18.11 64 bits.

  • Install EiffelStudio
From here on, $YOUR_INSTALLATION_PATH denotes the path name of the EiffelStudio installation.

See Also:
Software Installation for EiffelStudio

  • Check that the Eiffel-specific environment variables are set
They should be set in the ~/.bashrc control file (or /etc/profile.d/eiffel.sh if you want them for all users)

sudo gedit ~/.bashrc -- Export the following variables export ISE_EIFFEL=$YOUR_INSTALLATION_PATH/Eiffel_18.07 export ISE_PLATFORM=linux-x86-64 export PATH=$PATH:$ISE_EIFFEL/studio/spec/$ISE_PLATFORM/bin -- Refresh environment variables after edit . ~/.bashrc -- Or . /etc/profile.d/eiffel.sh if you put it there

  • Use the estudio command to check that EiffelStudio is installed and where it is'

which estudio

Note: You should see the path to EiffelStudio, for example: /opt/Eiffel_18.07/studio/spec/linux-x86-64/bin/estudio.

check EiffelStudio version using. ec -version

Note: You should see something like ISE EiffelStudio version 18.07.10.1981 GPL Edition - linux-x86-64

  • Check/Install PostgreSQL

-- Install PostgreSQL sudo apt install postgresql postgresql-contrib -- Check that PostgreSQL is working sudo -u postgres psql psql (10.5 (Ubuntu 10.5-0ubuntu0.18.04)) Type "help" for help. postgres=# -- Exit postgresql postgres=# \q

  • Install and Check ODBC Driver Manager and ODBC Driver for PostgreSQL

-- Install the UnixODBC Driver Manager and the ODBC driver for PostgreSQL sudo apt-get install unixodbc unixodbc-dev odbc-postgresql -- Check odbcinst -j unixODBC 2.3.4 DRIVERS............: /etc/odbcinst.ini SYSTEM DATA SOURCES: /etc/odbc.ini FILE DATA SOURCES..: /etc/ODBCDataSources USER DATA SOURCES..: /home/websocket/.odbc.ini SQLULEN Size.......: 8 SQLLEN Size........: 8 SQLSETPOSIROW Size.: 8

  • Configure PostgreSQL and ODBC Driver

-- Edit the file /etc/odbcinst.ini adding full path instead of file only [PostgreSQL] Description=PostgreSQL ODBC driver (ANSI version) Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so Setup=/usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so Debug=0 CommLog=1 UsageCount=1 [PostgreSQL Unicode] Description=PostgreSQL ODBC driver (Unicode version) Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so Setup=/usr/lib/x86_64-linux-gnu/odbc/libodbcpsqlS.so Debug=0 CommLog=1 UsageCount=1

  • Configure the Database name, username and password to use the Postgres ODBC Driver

-- Edit file /etc/odbc.ini [PODBC] Driver = PostgreSQL Unicode Description = PostgreSQL Data Source Servername = localhost Port = 5432 Protocol = 8.4 UserName = postgres Password = example Database = example -- The previous files tells PODBC to use the PostgreSQL Unicode driver. Using as postgres as a user, example as password, and to connect to PostgreSQL running on the localhost on port 5432.

  • Test the ODBC to PostgreSQL connection by running the isql command

Read the /etc/odbc.ini. isql -v PODBC encoding name too long +---------------------------------------+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +---------------------------------------+

  • Compile C code of the Eiffel library store:

cd $ISE_EIFFEL/library/store/dbms/rdbms/odbc/Clib; finish_freezing -library

Note: On debian at least before finish_freezing log in as superuser doing a sudo -i depending on the right and user setted for $ISE_EIFFEL/Eiffel_18.07 directory

  • Open EiffelStudio eSQL example and run it

The example is located on $ISE_EIFFEL/examples/store/esql/

-- You will see something like this. Database user authentication: Data Source Name: PODBC Name: postgres Password: example encoding name too long Welcome to the SQL interpreter Database used: DB Type 'exit' to terminate SQL> select * from cities; names location milan italy SQL> insert into cities values ('Madrid', 'Spain'); SQL> select * from cities; names location milan italy Madrid Spain SQL>