1

I build an application to do some number crunching with wxpython. I have to access the data from SQL Server 2005 for my purpose. I am using PYODBC and when I asked my server adminstrator, he provided me the server name and unique data ID for the database.

I don't see the syntax to access database with unique data ID in PYODBC as something like:

Conn=pyodbc.connect('DRIVER={SQL Server};SERVER=USMDUBEDAS215;DATABASE=spam;UID=usr,PWD=pwd')

when you have a database and table name. How can you access the database with server-name and Data_ID?

I don't know from where to start.

1 Answer 1

2

Try to look at the following link: http://code.google.com/p/pyodbc/wiki/GettingStarted

Link to connect method: http://code.google.com/p/pyodbc/wiki/Module#connect

Using the link above you can find the following sample code:

#Make a direct connection to a database and create a cursor.

cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=localhost;DATABASE=testdb;UID=me;PWD=pass')
cursor = cnxn.cursor()
cursor.execute("select user_id, user_name from users")
row = cursor.fetchone()
print 'name:', row[1]          # access by column index
print 'name:', row.user_name   # or access by name

I have tried it in our env and all works as expected

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.