Haskell, HDBC, ODBC, MySQL, and Mac OS X

I am trying to use Haskell (version 6.10.3) and HDBC to connect to a MySQL database. I decided to do this with Haskell ODBC. I used cabal to install HDBC (2.1.1) and HDBC-ODBC (2.1.0.0). I downloaded and installed the MySQL ODBC driver (5.1.5). I used macports to install unixODBC (2.2.14_1). All this on top of Mac OS X (10.5.8).

I mainly used the instructions on this page http://en.wikibooks.org/wiki/Haskell/Database . After about this point:

"# Add the mysql driver to the odbcinst.ini file (under $ ODBC_HOME / etc /) and your data source in $ HOME / .odbc.ini."

It looks like the macfix version of unixODBC version installs everything under / opt / local /. I put odbcinst.ini in / opt / local / etc / and I created .odbc.ini in my home directory that looks something like this (note that I experimented with UID and USERNAME and PWD vs PASSWORD):

[ODBC Data Sources]
myodbc = MySQL ODBC 5.1 Driver

[ODBC]
Trace = 0
TraceAutoStop = 0
TraceFile =
TraceLibrary =

[myodbc]
Driver = /usr/local/lib/libmyodbc5.so
DATABASE = [hidden]
DESCRIPTION = [hidden]
SERVER = localhost
PORT = 3306
UID = [hidden]
PWD = [hidden]
PASSWORD = [hidden]
USER = [hidden]

And I wrote and compiled this Haskell program:

import Database.HDBC.ODBC
import Database.HDBC
import system

main = do
  args <- getArgs
  c <- connectODBC (args !! 0)
  tables <- getTables c
  mapM_ putStrLn $ tables

DSN "DSN = myodbc", :

Database: SqlError 
  {seState = "[\"HY000\"]", 
    seNativeError = -1, 
    seErrorMsg = "connectODBC/sqlDriverConnect: 
      [\"1045: [unixODBC][MySQL][ODBC 5.1 Driver]Access 
        denied for user 'jamie'@'localhost' (using password: YES)\"]"}

, DSN "DSN = myodbc; UID = [hidden]; PWD = [hidden]", .

+3
2

unixODBC, Haskell/HDBC/HDBC-ODBC. "isql myodbc" " ". "isql -v myodbc" . isql [uid] [pwd] .

+1

iODBC, , Mac OS X Jaguar (10.2.x).

iODBC (Apple, , ), UnixODBC.

, ODBC Mac OS X -

/Library/ODBC/odbc.ini
/Library/ODBC/odbcinst.ini
/Users/*/Library/ODBC/odbc.ini
/Users/*/Library/ODBC/odbcinst.ini

, , . -

ln -s ~/Library/ODBC/odbc.ini ~/.odbc.ini

, ODBC MySQL, , ( ).

0

Source: https://habr.com/ru/post/1716448/


All Articles