Connecting to SQL-Server

G

Greg Lindstrom

Hello-

I'm running Python 2.3 on a Windows XP box and am trying to get connected to
an MS SQL-Server. I have found (seemingly) conflicting methods to connect
using the odbc module in the win32-all extensions. I have seen both of the
following:

db = odbc.odbc('DSN/UID/PASSWORD)
and
db=odbc.odbc('DSN=dsn;UID=uid;PWD=password)

I can connect when I use my computer, but when I transfer the code to a
production box I am greeted with an error that the login is not associated
with a trusted connection. So which, if either, of the above methods should
I use and what is the error about a trusted connection trying to tell me?

Thanks for your help!

Greg Lindstrom (501) 975-4859
NovaSys Health (e-mail address removed)

"We are the music makers, and we are the dreamers of dreams" W.W.
 
T

Tim Golden

[Greg Lindstrom]
I'm running Python 2.3 on a Windows XP box and am trying to get connected to
an MS SQL-Server. I have found (seemingly) conflicting methods to connect
using the odbc module in the win32-all extensions. I have seen both of the
following:

db = odbc.odbc('DSN/UID/PASSWORD)
and
db=odbc.odbc('DSN=dsn;UID=uid;PWD=password)

[... snip description of problem solved by other people ...]

I know I'm coming late to this particular party now that
others have solved the particular problem. But I wanted to
offer a couple of things. One is this page (just in case you
hadn't come across it):

http://www.able-consulting.com/ADO_Conn.htm

I come back here every time I have a problem with an
ODBC connection string.

On the back of that, I almost always use a DSN-less
connection something like this:

<code>
import odbc

dsn = [
"Driver={SQL Server}",
"Server=VODEV1",
"Database=EVOTEST",
"UID=evoreader",
"Pwd=***"
]

db = odbc.odbc (";".join (dsn))
</code>

or, for trusted connections:

<code>
import odbc

trusted_dsn = [
"Driver={SQL Server}",
"Server=VODEV1",
"Database=EVOTEST",
"Trusted_Connection=yes"
]

db = odbc.odbc (";".join (trusted_dsn))
</code>

Obviously the server / database etc. can be variables
pulled from a configuration file etc. This way, I
don't have to set up a system/user-dsn on each computer
I run on.

TJG
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Sharing Base Class members 0
Oracle Access via cx_Oracle 1
Pattern Matching 0
Boa Constructor Problem 5
mySQL access 2
Oracle Access via cx_Oracle 0
Machine identification 1
Pmw EntryWidget Help 1

Members online

Forum statistics

Threads
473,792
Messages
2,569,639
Members
45,353
Latest member
RogerDoger

Latest Threads

Top