Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » pyodbc: Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnectW)') [RSS Feed]

#1 Jan. 30, 2011 16:07:00

D.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

pyodbc: Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnectW)')


As far as I know, the only way to connect to MSSql using pyodbc on
Linux is to use FreeTDS.

conn = pyodbc.connect(r"DRIVER={FreeTDS};SERVER=testserver
\mssql2008;DATABASE=eoffice;UID=erp;PWD=123")

The "SQL Server" driver is a Windows driver and the above connection
string might work on the same Windows machine that you used to test
the C#.NET connection. Also, if you're putting a backslash in a
string, it either needs to be a raw string or needs to be escaped. I
assume that since you posted this to the Django list that you intend
to use it with django-pyodbc.

On Jan 30, 1:31 am, Orgil <orgi...@gmail.com> wrote:
> Hello,
> I have pyodbc-2.1.8 and python-2.6 on ubuntu-10.4.
> I tried to connect to MSSQL2008 database server which is on windows7.
> My code is below:
> -----------------------
> import pyodbc
> conn = pyodbc.connect('DRIVER={SQL Server};SERVER=testserver
> \mssql2008;DATABASE=eoffice;UID=erp;PWD=123')
> -----------------------
> When I run this code, the following error occurs:
> Error: ('IM002', ' Data source name
> not found, and no default driver specified (0) (SQLDriverConnectW)')
>
> I tested the connection string using System.Data.Odbc library on
> c#.net. It was fine.
> I have no idea to solve my problem because of so general error
> message.
>
> Please share your experience!
>
> regards,
> Orgil

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Jan. 31, 2011 04:33:35

O.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

pyodbc: Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnectW)')


> conn = pyodbc.connect(r"DRIVER={FreeTDS};SERVER=testserver
> \mssql2008;DATABASE=eoffice;UID=erp;PWD=123")

Thanks for your reply, David!
You gave me great advice!
As you suggest, now I my connection is fine!
But there is one another problem occurred!
When I run the Select query, result is non unicode data while select
query reads nvarchar column from mssql database. My code is below:
------------------
import pyodbc
conn = pyodbc.connect(r'DRIVER={FreeTDS};SERVER=testserver
\mssql2008;DATABASE=eoffice;UID=erp;PWD=123;')
crms = conn.cursor()
crms.execute('SELECT cc_Name FROM tblHR_CodeClass')
for line in crms:
print 'cc_Name: %s' % (line.cc_Name)
break
conn.close()
------------------
Result is 'cc_Name: ?????, ???'. But I expected the result would be
'cc_Name: Aймаг, хот' because actual data is 'Aймаг, хот'.

Here is my question: Does the pyodbc library support Unicode?

regards,
Orgil

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » pyodbc: Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnectW)') [RSS Feed]

Board footer

Moderator control

Enjoy the 23rd of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support