odbc under osx 10.7 - mysql

I'm trying to install an ODBC driver under MacOSX 10.7 (Lion) since the last few hours... But I can't get it to work. I need one for the RODBC package in R to work with a DB.
Under 10.6 everything worked fine :-\
The old drivers are installed, but when I test it with /usr/bin/iodbctest I get the following message:
iODBC Demonstration program
This program shows an interactive SQL processor
Driver Manager: 03.52.0607.1008
Enter ODBC connect string (? shows list): ?
DSN | Driver
------------------------------------------------------------------------------
lugv | MySQL ODBC 5.1 Driver
Enter ODBC connect string (? shows list): lugv
1: SQLDriverConnect = [iODBC][Driver Manager]dlopen(/usr/local/lib/libmyodbc5.so, 6): no suitable image found. Did find:
/usr/local/lib/libmyodbc5.so: mach-o, but wrong architecture (0) SQLSTATE=00000
2: SQLDriverConnect = [iODBC][Driver Manager]Specified driver could not be loaded (0) SQLSTATE=IM003
When I download the newest MYSQL ODBC Connector, it doesn't compile anymore and also doesn't have a bin or lib folder as mentioned in the manual...
Does someone have an idea?
Thanks!

Related

Error trying to connect Power BI Desktop with MariaDB running on Docker CentOS 7

I was trying to make the connection but Power BI shows this error:
"The 'Driver' property with value '{MariaDB ODBC 3.1 Driver}' doesn't correspond to an installed ODBC driver."
I've been following this site to configure the ODBC Driver :
https://mariadb.com/kb/en/about-mariadb-connector-odbc/
this one for the data source:
https://mariadb.com/kb/en/creating-a-data-source-with-mariadb-connectorodbc/
and this one to make the connection:
https://mariadb.com/resources/blog/getting-started-with-the-mariadb-direct-query-adapter-for-microsoft-power-bi/
I followed all the steps, even when i try :
$ isql MariaDB-server
The connection is succesfull
These are my:
odbc.ini
[MariaDB-server]
Description=MariaDB server
Driver=MariaDB ODBC 3.1 Driver
Trace=Yes
TraceFile=/tmp/trace.log
SERVER=xxx.x.x.x
USER=root
PASSWORD=xx
DATABASE=powerbiTest
PORT=3306
odbcinst.ini:
[MariaDB ODBC 3.1 Driver]
Description=MariaDB Connector/ODBC
Driver=/usr/lib64/libmaodbc.so
Setup=/usr/lib64/libodbcmyS.so
Driver64=/usr/lib64/libmaodbc.so
UsageCount=3
odbcinst -j
unixODBC 2.3.1
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
What ive tried
1- Re-installing Power Bi
2- Creating another Docker Container
3- Installing ODBC Driver from source
4- Using MariaDB driver as Default modifying the .ini files
5- Changing parameters like servername, password ,etc
Id be grateful if anyone could help me!
Thanks!

Access MySQL database in R on Mac OS X

I am having problems accessing my MySQL database from R on mac (Mac OS X 10.11.2). The following code:
library("RODBC")
mycom <- odbcConnect("wsn_mysql_5", uid="root", pwd="*****")
Gives this error:
1: In RODBC::odbcDriverConnect("DSN=wsn_mysql_5;UID=root;PWD=****") :
[RODBC] ERROR: state 00000, code 15509574, message
[iODBC][DriverManager]dlopen(/usr/local/lib/libmyodbc5a.so,
6): no suitable image found. Did find:
/usr/local/lib/libmyodbc5a.so: mach-o, but wrong architecture
2: In RODBC::odbcDriverConnect("DSN=wsn_mysql_5;UID=root;PWD=****") :
[RODBC] ERROR: state IM003, code 15509574, message
[iODBC][Driver Manager]Specified driver could not be loaded
What I have tried so far:
I installed iODBC driver manager 3.52.12.
I installed MySQL connector odbc-5.3.6-osx10.11-x86-64bit and created a DSN (server=localhost, user=root, password=*****,database=wsn_db).
I was getting this error when testing it in iODBC Administrator:
[iODBC][Driver manager]dlopen(/usr/local/lib/libmyodbc5w.so, 6): no suitable image found.
Did find: /usr/local/lib/libmyodbc5w.so: mach -o, but wrong architecture.
How to add ODBC to MAMP on OSX led me to think that is was a 32-bit vs 64-bit problem.
So I installed MySQL connector odbc-5.2.7-osx10.7-x86-32bit which is the most recent 32-bit version I found. When I test this with iODBC Administrator, it seems to work, but I get the error mentioned at the beginning when I try the code in R.
The FAQ of iODBC says the following regarding this type of error:
[iODBC] [Driver Manager]Specified driver could not be loaded
There are a few reasons why this could occur, and thinking through the architecture helps. Your application has loaded libiodbc successfully, and it has found an odbc.ini file (or equivalent through the ODBCINI environment variable), and it has found a DSN within that odbc.ini that matches the name requested in your connection.
However, the driver manager has had problems loading the library specified in the `Driver=' line of that DSN definition. Either it doesn't exist, or its permissions are insufficient to allow your application to load it (it must be readable and executable, and the directories leading down to it must be executable), or maybe the file is not a dynamic library - it could be a static library (a *.a file except on AIX) or is otherwise corrupted. These are all things to check, or you may be best off reinstalling the driver if all the permissions check out.
So I checked the permission, but they were correct.
I also reinstalled the driver, but it didn't change anything.
After reading this, I checked odbc.ini and obdcinst.ini.
I changed odbc.ini to:
[ODBC Data Sources]
wsn_mysql_7 = wsn_mysql_7
[ODBC]
TraceLibrary=
[wsn_mysql_7]
Driver = /usr/local/lib/libmyodbc5w.so
DATABASE = wsn_db
DESCRIPTION = DSN for wsn_db in R
SERVER = localhost
UID = root
PASSWORD = *****
and odbcinst.ini to
[ODBC Drivers]
MySQL ODBC 5.2 ANSI Driver=Installed
MySQL ODBC 5.2 Unicode Driver=Installed
[ODBC Connection Pooling]
PerfMon=0
Retry Wait=
[MySQL ODBC 5.2 ANSI Driver]
Driver = /usr/local/lib/libmyodbc5a.so
Description = mySQL driver
Threading = 0
[MySQL ODBC 5.2 Unicode Driver]
Driver = /usr/local/lib/libmyodbc5w.so
Description = mySQL driver
Threading = 0
But it didn't seem to change anything.
I also tried an alternative RODBC code based on this question.
mycom <- odbcDriverConnect("Provider=MSDASQL;Driver={MySQL ODBC 5.2 UNICODE Driver};
Server=localhost;database=wsn_db;Uid=root;Pwd=*****;Option=3")
I am not sure what to do next? Even a completely different way to access the mySQL data in R would help.
I finally manage to have a working configuration by using unixODBC and using a 64-bit ANSI connector. If you are trying to connect to a MySQL database with RODBC I recommend:
To follow this tutorial to install unixODBC and RODBC
Install the latest MySQL ODBC connector. I installed mysql-connector-odbc-5.3.6-osx10.11-x86-64bit. I had to install from tar since the installer didn't work. The instructions are here.
I used ODBC Administrator to configure the DSN, but I guess the instruction from [Hiltmon's tutorial] might work as well.
I first used the Unicode driver, but got the following error:
Warning messages:
1: In RODBC::odbcDriverConnect("DSN=wsn_db_dsn;UID=root;PWD=****") :
[RODBC] ERROR: state H, code 0, message [unixODBC][
2: In RODBC::odbcDriverConnect("DSN=wsn_db_dsn;UID=root;PWD=****") :
ODBC connection failed
I corrected this by selecting the ANSI driver as suggested in RODBC error - ODBC connection failed - can't connect to MySQL with my mac (mavericks).
I hope this can save time to someone.

How to solve the "Data source name not found and no default driver specified"

I hade my website(ASP.NET 4.5) working with MySQL ODBC 5.1 but while having this problem : https://stackoverflow.com/questions/29080505/server-does-not-support-4-byte-encoded-after-update I tried to install MySQL ODBC 5.3.4 and change the connection string from 5.1 to 5.3. Now I got the ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified exception that many others have hade.
Anyway, I uninstalled 5.3 and 5.1 and then installed 5.1 64 bit go my Windows 8.1 64 but I still gets the same exception!? I tried restart and uninstall/install again but it throws the same exception.
I have tried to add the driver(pointing out the server) in the Controlpanel > ODBC Data Source 64 > System DSN but it does still not work.
Edit : I can connect and work with the database with the MySQl Workbench without problems.
Exact exception : ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
This is the current connectionstring :
<add name="MySite" connectionString="DRIVER={MySQL ODBC 5.1 Driver};SERVER=127.0.0.1;PORT=3306;DATABASE=195414-MySite;USER=[myuser];PASSWORD=[mypassword] OPTION=3"/>
The Server is set to 127.0.0.1 becouse Im using SSH and this have worked fine before.
I tried to uninstall all mySQL ODBC drivers and then installthe 32 bit 5.1 and that worked fine! It did however still not work with the 5.3 32 bit.

pyodbc + MySQL + Windows: Data source name not found and no default driver specified

I am trying to connect to MySQL 5.6 on a Windows Server 2008 R2 localhost with pyodbc. I used the full installation for the MySQL instance on the localhost, including the ODBC connector. I have it connecting to a remote SQL Server instance beautifully, but for the life of me I can't get it to connect to the local MySQL instance. I am using this guide from connectionstrings.com as reference.
Here's some code:
import pyodbc
def create_mssql_conn():
return pyodbc.connect(r'Driver={SQL Server};Server=MSSQLSRV;Database=ecomm;Trusted_Connection=yes;')
def create_mysql_conn():
return pyodbc.connect(r'Provider=MSDASQL;Driver={MySQL ODBC 5.6 UNICODE Driver};Server=127.0.0.1;Database=ecomm;User=root;Password=myP#$$w0rd;Option=3;')
# conn = create_mssql_conn() # This one works
conn = create_mysql_conn() # This one breaks
cursor = conn.cursor()
cursor.execute('SELECT * FROM inventory')
while 1:
row = cursor.fetchone()
if not row:
break
print row
Here is the error:
pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
I tried everything from adding Provider=MSDASQL; to changing ANSI to UNICODE in the connection string. Any suggestions?
I was having a similar issue. I am using windows 8, and mysql.
The way I solved the problem was by going into my
control panel>Systems and Security>Administrative Tools.>ODBC Data Sources
Either the 32 bit or 64 bit version depending on your computer.
Then you click on the System DNS file. If you do not see any MySQL driver you have to click ADD. It brings up a list, from that list select the MySQL driver.
For me it was MySQL ODBC 5.3 ANSI(they have a unicode driver also). Click finish. Once you do that then you have to change your connection line in your code to the corresponding Driver that you just filled out.
Ex:
def create_mysql_conn():
return pyodbc.connect(r'Driver={MySQL ODBC 5.3 ANSI Driver};Server=MSSQLSRV;Database=ecomm;Trusted_Connection=yes;')
This should work, or at least it solved my connection issue because I was getting all sorts of different errors with everything I tried. This was what solved the issue for me.
In Win64 there are two ODBC environments: 32 and 64 bit and you can work with Python 32 bit or Python 64 bit. Check what version of Python you use and then use proper version of odbcad32.exe (32 bit version is located in the SysWoW64 directory) to create SystemDSN. With SystemDSN you can check if you can connect to the database. Then try to connect to DB from Python code.
You can list ODBC datasources available to pyodbc via my code recipe: https://code.activestate.com/recipes/578815-printing-list-of-odbc-data-sources-with-pyodbc-mod/
Head to Administrative Tools and the ODBC Data Sources. You should click on the DNS file. Most likely you'd see Microsoft Access and excel as the only data sources available, so you need to add your SQL Server. Mine was SQL Server 2008 R2, and so far, it has worked.
For the error mentioned
"pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')"
I installed the 'Microsoft Access Database Engine 2010 Redistributable 64-bit' as I have 64-bit system and then added the DSN in the directory of MS Access database and it's working now.
Here is the link of the video for how to create DSN and connect to python.
https://www.youtube.com/watch?v=zw9P2wSnoIo

Error Trying to Connect R to MySQL using RODBC

I am attempting to connect R to a MySQL database via RODBC (in Win 7 environment), but cannot get past the following error:
[RODBC] ERROR: state IM014, code 0, message [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
After entering the following command:
odbcConnect(dsn,uid="My_UID",pwd="My_PWD")
I have successfully created a driver for the database by following the odbc wizard, and have installed the RODBC package into RStudio (ver 0.98.490). The MySQL is running on 32bit, I have the 32bit driver installed and working, and my RStudio is also 32bit. I know that the driver is working since both the test connection in config. works, as do queries run on excel using the driver.
What can I do to get the connection to work in R?
(Previous responses to this question seem to have been removed.)
Thanks in advance!
I faced a similar RODBC connectivity issue using DSN, where R was crashing abruptly without any logs/error trace. I tried with DSN-less ODBC connection API, it works fine.
odbcDriverConnect("SERVERNAME=;DRIVER={};DATABASE=;UID=;PWD=;")
Steps:
1. Install ODBC driver
2. Define VNode (host, listen address, protocol)
3. Use the odbcDriverConnect API
Docs:
http://cran.r-project.org/web/packages/RODBC/RODBC.pdf
http://cran.r-project.org/web/packages/RODBC/vignettes/RODBC.pdf
Hope this helps.