I´m going to develop a Symfony2 application in my Mac OSX with MAMP, but the database (a Microsoft SQL Server one) is in another computer.
I setup everything (I followed this instruction http://jesusomar.com/2011/07/22/mamp-php-and-mssql )and if I check phpinfo() I see that mssql is active, but I´m getting this error:
[PDOException]
could not find driver
any help or clue? Thanks in advance
The first step is to check if FreeTDS is installed. You can run tsql -C to get information about MSSQL libraries in your computer. You should get something like this:
Version: freetds v0.91
freetds.conf directory: /usr/local/Cellar/freetds/0.91/etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 7.1
iODBC: no
unixodbc: no
SSPI "trusted" logins: no
Kerberos: no
If FreeTDS is not installed, you can do it with Homebrew (for example): brew install freetds.
Now you can use MssqlBundle to connect with your database.
Related
I'm facing an issue in API call due to DB connection failure. We have tried for concurrent 90 calls to fetch some details based on some code which got failed in 1 percentage due to DB connection failure. Here is the error message “SQLSTATE[01002] Adaptive Server connection failed (severity 9)” while connecting to the DB. There are so many failures happening recently in API call due to the DB connection failure.
Is there any work around or permanent fix for this issue?
Some info,
rpm -qa | grep freetds
freetds-0.91-2.el6.x86_64 freetds-devel-0.91-2.el6.x86_64
tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v0.91
freetds.conf directory: /etc
MS db-lib source compatibility: yes
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: yes
Please give your hands to fix this issue.
I am trying to connect to remote Microsoft SQL server 2012 service pack 2 database from my Linux machine which is having php 5.3, php-mssql support and mysql version 5.5 enabled. Meanwhile I am getting below error message even if the login details are correct.
The ms-sql database is using Persian collation which cannot be changed. Is there any possible fix for this?
[root#i]# /usr/bin/tsql -H remove-server-ip -p 1433 -U mssql-user
locale is "en_IN"
locale charset is "UTF-8"
using default charset "UTF-8"
Msg 4075 (severity 16, state 1) from RAHKARAN Line 1:
"
The USE database statement failed because the database collation
Persian_100_CI_AI is not recognized by older client drivers. Try
upgrading the client operating system or applying a service update to
the database client software, or use a different collation. See SQL
Server Books Online for more information on changing collations."
Msg 18456 (severity 14, state 1) from RAHKARAN Line 1:
"Login failed for user 'mssql-user'."
Error 20002 (severity 9):
Adaptive Server connection failed
There was a problem connecting to the server
Error 20002 (severity 9)
Freetds version is below
tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v0.91
freetds.conf directory: /etc
MS db-lib source compatibility: yes
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: yes
I'm trying to connect to a MS SQL Server instance using tsql (to troubleshoot not being able to connect with django-pymssql).
I can connect fine to the server (running on Amazon RDS, latest SQL Server version from on there) from a VM running SQL Server management studio, but from my native Ubuntu 15.10 env I get a login failed error.
Using the following:
tsql -H <hostname> -p 1433 -U <user> -P <mypassword>
I get:
locale is "en_GB.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Msg 18456 (severity 14, state 1) from EC2AMAZ-U1TAK71 Line 1:
"Login failed for user 'sa'."
Error 20002 (severity 9):
Adaptive Server connection failed
There was a problem connecting to the server
As I can connect in management studio with mixed mode auth using the same creds I'm suspecting this isn't the real error.
Anyone have any ideas how I can troubleshoot?
tsql -C shows:
Compile-time settings (established with the "configure" script)
Version: freetds v0.91
freetds.conf directory: /etc/freetds
MS db-lib source compatibility: no
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: yes
Thanks loads for any pointers.!
(Accidentally posted this to AskUbuntu so have moved here. Sorry).
Answering my own question. Turns out it was down to the password being too long. I experimented with it, and any password longer than 30 characters didn't work. Seems to be a known issue with freetds.
Thanks.
I'm trying to connect to a SQL Server Express database using SQLALchemy and pyodbc, but I'm continuously getting the error:
(pyodbc.Error) ('IM002', '[IM002] [unixODBC][Driver Manager]Data
source name not found, and no default driver specified (0)
(SQLDriverConnect)')
And I really don't understand if my engine url is wrong or what else.
My scenario is the following:
I'm on a Mac
I have a docker container (based on a Debian image with unixodbc and unixodbc-dev) in which my python app tries to connect to...
a virtualbox virtual machine running windows 8 with SQL express 2014...
I configured a user for the SQL express, with SQL Server authentication:
user: ar_user
password: ar_psw
...then:
I configured TCP ports as 1433 and disabled dynamic ports (SQL Server Configuration Manager > Network Configurations > Protocols).
I turned off Windows Firewall.
I used an Host-only adapter for the VM running windows8
now...
The VM is accessible from the host (my mac), since a:
ping -c 3 vm-ip
succeed!
But although I tried every possible permutation of user, password, ip, server name and port:
'mssql+pyodbc://ar_user:ar_psw#vm-ip/master'
'mssql+pyodbc://ar_user:ar_psw#vm-ip:1433/master'
'mssql+pyodbc://IE10WIN8\\SQLEXPRESS'
'mssql+pyodbc://ar_user:ar_psw#IE10WIN8\\SQLEXPRESS'
'mssql+pyodbc://ar_user:ar_psw#IE10WIN8\\SQLEXPRESS:1433'
'mssql+pyodbc://ar_user:ar_psw#IE10WIN8\\SQLEXPRESS:1433/master'
...and many more!
I always get the "datasource not found error".
What should I do?
ps: the vm is pingable even in the docker container!
UPDATE (solved but not 100%):
I solved in this way:
I configured FreeTDS driver using /etc/odbcinst.ini in this way:
[FreeTDS]
Description = TDS driver (Sybase/MS SQL)
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
client charset = UTF-8
and in /etc/freetds/freetds.conf:
[global]
tds version = 7.3
client charset = UTF-8
Then I created the engine using the following string:
'mssql+pyodbc://my_user:my_psw#machine_ip:1433/my_db?driver=FreeTDS'
It seems to work properly, but I get this warning:
SAWarning: Unrecognized server version info '95.12.255'. Version
specific behaviors may not function properly. If using ODBC with
FreeTDS, ensure TDS_VERSION 7.0 through 7.3, not 4.2, is configured in
the FreeTDS configuration.
I also defined the TDS version using environment variables but it doesn't fix the issue... any idea?
I wrote a tutorial here of how to do this. Essentially, you need to:
brew install unixodbc
brew install freetds --with-unixodbc
Add the freetds driver to odbcinst.ini
Add a DSN (Domain Source Name) to odbc.ini named "MY_DSN"
pip install pyodbc
e = create_engine("mssql+pyodbc://username:password#MY_DSN")
The walkthrough here does a much more thorough job of explaining this, including issues with SQL Server/FreeTDS Protocol Version Compatibility.
I've installed iODBC over the package (http://www.iodbc.org/dataspace/iodbc/wiki/iODBC/) and set up all config files as described here: http://blog.opensteam.net/past/2009/1/28/rails_ms_sql_on_mac/
I set up the same thing on a Linux machine and it worked fine. On my Mac OSX 10.6.4, I get this error if i test the connection:
xxx#xxx:/opt/local/include$ iodbctest "dsn=res;uid=user;pwd=pass"
iODBC Demonstration program
This program shows an interactive SQL processor
Driver Manager: 03.52.0709.0909
1: SQLDriverConnect = [iODBC][Driver Manager]dlopen(/opt/local/lib/libtdsodbc.so, 6): Symbol not found: _CreateDataSource
Referenced from: /usr/lib/libiodbcinst.2.dylib
Expected in: flat namespace
(0) SQLSTATE=00000
2: SQLDriverConnect = [iODBC][Driver Manager]Specified driver could not be loaded (0) SQLSTATE=IM003
I have no idea how to debug this :(
It would be interesting to see what params you have in your odbc.ini and odbcinst.ini files for the DSN and FreeTDS driver being used ?
Looks as if the Apple iODBC Driver Manager is not able to load setup routines required for the driver nor does the FreeTDS driver itself.
The OpenLink iODBC Driver Manager for Mac OS X (which Apples bundled one is based on) is Framework based and does include routines for loading generic setup and login dialogs for those ODBC drivers that do not have built in one. You can download it free (as it is open source) from the following location:
http://www.iodbc.org/downloads/iODBC/iodbc-sdk-3.52.7-macosx-10.5.dmg (it is for 10.5 and 10.6)
Steps to follow:
brew install freetds
subl ~/Library/ODBC/odbc.ini
[sqlserver01]
Driver=/usr/local/lib/libtdsodbc.so
TDS_Version=7.2
Server=192.168.8.7
Port = 1433
Trace = Yes
Description=ds01
# Database=
# can't specify username and password for freetds
subl ~/.freetds.conf
host = ds01.uswa.net # server name
port = 1433
tds version = 8.0 # works with 2008+
sudo pip install pyodbc
sudo pip install sqlsoup
The Python Connection String would look like this:
# Steve is my username; steve is my password; #sqlserver01 is my DSN in odbc.ini
db = sqlsoup.SQLSoup('mssql+pyodbc://Steve:steve#sqlserver01')
The SQLAlchemy way would look like this:
engine = create_engine('mssql+pyodbc://Steve:steve#sqlserver01')`
Do whatever queries…
I had the same problem, linux works, Lion 10.7 not (I guess same problem for 10.6).
I'm using FreeTDS driver to connect, compiling from the source code: it looks like that when compiling, libtdsodbc.so is compiled for the wrong architecture or 32bit/64bit.
I followed this guide (excluding Excel part), and everything worked like a charm.
http://asmiler.blogspot.fr/2011/10/accessing-mssql-databases-from-excel.html