ODBC driver for HDBC https://github.com/hdbc/hdbc-odbc
|Latest on Hackage:||188.8.131.52|
This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.
Welcome to HDBC, Haskell Database Connectivity.
This package provides a database backend driver for ODBC. You should be able to use any ODBC front-end with it.
Please see HDBC itself for documentation on use.
This package provides one function in module Database.HDBC.ODBC:
Connect to an ODBC server. For information on the meaning of the passed string, please see: http://msdn2.microsoft.com/en-us/library/ms715433(VS.85).aspx
connectODBC :: String -> IO Connection
For example, you might use
connectODBC as follows:
For more information about HDBC-ODBC, please visit the wiki.
Differences from HDBC standard
None known at this time.
Important note for MySQL users:
Unless you are going to use InnoDB tables, you are strongly encouraged to set
Option = 262144
in your odbc.ini (for Unix users), or to disable transaction support in your DSN setup for Windows users.
If you fail to do this, the MySQL ODBC driver will incorrectly state that it supports transactions. dbTransactionSupport will incorrectly return True. commit and rollback will then silently fail. This is certainly NOT what you want. It is a bug (or misfeature) in the MySQL driver, not in HDBC.
You should ignore this advice if you are using InnoDB tables.
For the error "2013: Mysql server has gone away" error message, you'll have to use withRTSSignalsBlocked from the HDBC-mysql package.
query conn stmStr binds = withRTSSignalsBlocked $ quickQuery conn stmStr binds
Here are some instructions to set up ODBC with a sqlite3 backend, and how to communicate with that database with HDBC-ODBC. These instructions are written to work with Ubuntu 11.10.
First, we'll need to install the appropriate libraries:
sudo apt-get install unixodbc unixodbc-dev unixodbc-bin sudo apt-get install libsqliteodbc
Verify that the sqlite ODBC drivers have been set up correctly:
odbcinst -q -d
This should return:
Next, fire up the
ODBCConfig too to set up a new DSN:
If you want to run the HDBC test suite, then set your DSN to
and set up to connect to a database of your choice, such as an empty file
You can check that everything is working appropriately in ghci:
ghci> :m + Database.HDBC Database.HDBC.ODBC ghci> conn <- connectODBC "DSN=hdbctest" ghci> hdbcDriverName conn "odbc" ghci> hdbcClientVer conn "03.52"
You can then run some tests on your database:
cd testsrc runhaskell runtests.hs
Contributions are welcome! If you would like to contribute, please fork the the github repository, and submit a pull request.
* Switched to using UTF-8 encoding for binding WCHAR_T values on Linux. Earlier version tried
to use C wchar_t type, which confused some (in particular PostgreSQL) drivers.
184.108.40.206 - 12 Nov 2014
* Changed parameter binding implementation to fix bugs with wide character strings and binary
data not handled well with Microsoft SQL Server on Windows.
* Implemented atomic reference counting to avoid race conditions in native code when running
* Implemented workaround for the SQL Server ODBC Driver deadlock, which occured if cursor over a
statement that was in the process of fetching data over the network got closed.