HDBC-odbc: ODBC driver for HDBC

[ bsd3, database, library ] [ Propose Tags ]

This package provides an ODBC database backend for HDBC. It is cross-platform and supports unixODBC on UnixLinuxPOSIX platforms and Microsoft ODBC on Windows. It is also the preferred way to access MySQL databases from Haskell.


[Skip to Readme]

Modules

[Last Documentation]

  • Database
    • HDBC
      • Database.HDBC.ODBC

Flags

Automatic Flags
NameDescriptionDefault
buildtests

Build the executable to run unit tests

Disabled
buildstresstest

Build the stress testing executable

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 1.0.1.0, 1.1.3.0, 1.1.3.1, 1.1.4.0, 1.1.4.1, 1.1.4.2, 1.1.4.3, 1.1.4.4, 1.1.6.0, 2.0.0.0, 2.1.0.0, 2.2.0.0, 2.2.3.0, 2.2.3.1, 2.2.3.2, 2.3.1.0, 2.3.1.1, 2.4.0.0, 2.4.0.1, 2.5.0.0, 2.5.0.1, 2.5.1.1, 2.6.0.0
Change log changelog.txt
Dependencies base (>=4.3.1.0 && <5), bytestring, concurrent-extra (>=0.7.0.8), containers, convertible, HDBC (>=2.1.0), HDBC-odbc, HUnit, mtl, old-locale, old-time, QuickCheck, random, resource-pool, testpack, time (>=1.2.0.3), utf8-string [details]
License BSD-3-Clause
Copyright Copyright (c) 2005-2014 John Goerzen, Nicolas Wu, Anton Dessiatov
Author John Goerzen
Maintainer Anton Dessiatov <anton.dessiatov@gmail.com>
Category Database
Home page https://github.com/hdbc/hdbc-odbc
Uploaded by anton_dessiatov at 2019-04-08T12:32:11Z
Distributions Debian:2.5.0.1, NixOS:2.6.0.0
Reverse Dependencies 9 direct, 1 indirect [details]
Executables stresstest, runtests
Downloads 24928 total (42 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2019-04-08 [all 3 reports]

Readme for HDBC-odbc-2.6.0.0

[back to package description]

HDBC-ODBC

CircleCI

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:

connectODBC "DSN=hdbctest1"

For more information about HDBC-ODBC, please visit the wiki.

Differences from HDBC standard

None known at this time.

MySQL note

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

Getting Started

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:

[SQLite]
[SQLite3]

Next, fire up the ODBCConfig too to set up a new DSN:

ODBCConfig

If you want to run the HDBC test suite, then set your DSN to hdbctest, and set up to connect to a database of your choice, such as an empty file in the hdbc-odbc/testsrc directory:

touch hdbc-odbc/testsrc/hdbctest.db

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

Contributing

Contributions are welcome! If you would like to contribute, please fork the the github repository, and submit a pull request.