Personal tools

MetaHDBC Install

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
m (removed specific database vendor information for linux)
m (PostgreSQL, MySQL, SQLite, ...)
Line 76: Line 76:
 
== PostgreSQL, MySQL, SQLite, ... ==
 
== PostgreSQL, MySQL, SQLite, ... ==
   
[http://www.unixodbc.org/odbcinst.html see here for instruction for setup of UnixODBC on Linux].
+
[http://www.unixodbc.org/odbcinst.html See here for instruction for setup of UnixODBC on Linux].
   
 
To run the tests you need to setup a database. Database name and login information can be found in test/DSN.hs.
 
To run the tests you need to setup a database. Database name and login information can be found in test/DSN.hs.

Revision as of 17:00, 31 July 2011

This page is about installing MetaHDBC.

Contents

1 Installing MetaHDBC, HDBC and HDBC-odbc

On Unix:

2 Running Test

After installation you can run some tests. They are located in the test directory. But beware, the tests drops tables, creates tables, and other data manipulation both at compile and run -time. So be sure that you do not accidentally destroy valuable data.

Before running the test you will need to install one or more databases management system (DBMSs). You can see the following section for some guidance.

After installing databases you need to:

  • Setup your data source names in test/DSN.hs
  • "runhaskell CreateTables.hs" to create database tables. You will need specify which DBMSs you want to create tables for. Use " runhaskell CreateTables.hs help" for guidance.
  • use "make DBMS/run<some DBMS>" to run the tests for a specific DBMS.

3 Databases on Linux

To use MetaHDBC you will need a database. This section describes how to setup various databases for Linux.

You can use the popular open source databases PostgreSQL, MySQL and SQLite with MetaHDBC. They are all likely to be part of your Linux distribution. These databases in conjunction with MetaHDBC will provide you with SQL syntax check and it will give type inference for returned values. However, they will 'not' infer the types of positional parameters, as these databases do not support the ODBC function SQLDescribeParam properly.

For full type inference you can use DB2 or MS SQL Server.

The setup instructions below, have to be adapted to your particular system

3.1 DB2

DB2 is a pain to install, but using DB2 with MetaHDBC is attractive as DB2 supports the ODBC functions necessary for doing full type inference. The Express-C edition is also free of charge and Ubuntu makes DB2 Express-C available though their partner program.

DB2 Howto will help you install DB2. There are explanations for various flavors of Linux.

Before installing DB2 you should be given this fair warning. When I installed this .deb package, pointed to from the howto, the install script accidentally overwrote a file in /usr/include. This may or may not be true for the other types of packages pointed to from the howto.

The error is explained in more detail here.

3.1.1 Creating a database

To create a test database that MetaHDBC can use, do:

> su - db2inst1
> db2 create database <database name>
DB20000I  The CREATE DATABASE command completed successfully.

The database name must maximally be eight characters. Make a database called MHdbcDB2, if you want it to be usable from the MetaHDBC test programs.

3.1.2 UnixODBC setup

You need to add the DB2 driver to /etc/odbcinst.ini, and it is something like (but it varies from version to version):

[DB2]
Description     = DB2 Driver
Driver          = /opt/ibm/db2exc/V9.5/lib32/libdb2.so
FileUsage       = 1
DontDLClose     = 1

and your /etc/odbc.ini should look something like:

[MHdbcDB2]
Description     = Test DB2
Driver          = DB2
USER            = db2inst1
PASSWD          = <password of db2inst1 user>

The password is ibmdb2 if you have not changed it after installing DB2.

The UnixODBC.org site also has documentation for setting up ODBC for DB2.

3.2 PostgreSQL, MySQL, SQLite, ...

See here for instruction for setup of UnixODBC on Linux.

To run the tests you need to setup a database. Database name and login information can be found in test/DSN.hs.

4 Databases on Windows

MetaHDBC has been reported to work with Microsoft SQL Server. However, Microsoft's ODBC driver do not support UTF-8. Andrey Galysh has made a workaround for the UTF-8 problem here.