From c3377a0442c4049a577d68fb9e0e76a5896fae48 Mon Sep 17 00:00:00 2001 From: eiffel-org Date: Thu, 18 Oct 2018 15:18:11 +0000 Subject: [PATCH] Updated wikipage EiffelStore ODBC with PostgreSQL. (Signed-off-by:javier). git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@2087 abb3cda0-5349-4a8f-a601-0c33ac3a8c38 --- .../EiffelStore-ODBC-with-PostgreSQL.wiki | 180 ++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 documentation/18.07/solutions/database-access/eiffelstore/EiffelStore-ODBC-with-PostgreSQL.wiki diff --git a/documentation/18.07/solutions/database-access/eiffelstore/EiffelStore-ODBC-with-PostgreSQL.wiki b/documentation/18.07/solutions/database-access/eiffelstore/EiffelStore-ODBC-with-PostgreSQL.wiki new file mode 100644 index 00000000..ccc1fe2a --- /dev/null +++ b/documentation/18.07/solutions/database-access/eiffelstore/EiffelStore-ODBC-with-PostgreSQL.wiki @@ -0,0 +1,180 @@ +[[Property:modification_date|Thu, 18 Oct 2018 15:18:11 GMT]] +[[Property:publication_date|Mon, 24 Sep 2018 12:04:18 GMT]] +[[Property:uuid|6F78A05A-2054-4150-84FC-1D8663CA76E6]] +[[Property:weight|5]] +[[Property:title|EiffelStore ODBC with PostgreSQL]] +[[Property:link_title|EiffelStore ODBC]] +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. }} + +* '''Install EiffelStudio''' + From here on, $YOUR_INSTALLATION_PATH denotes the path name of the EiffelStudio installation. + +{{seealso|
+[[Software_Installation_for_EiffelStudio|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 $YOUR_INSTALLATION_PATH/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''' }} + +* '''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> + +