Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Python adodb

Reply
Thread Tools

Python adodb

 
 
gt_mac@yahoo.com
Guest
Posts: n/a
 
      10-12-2005
In trying to use the adodb module, I have had good success. However I
need to access a database with a username and password at this time.
And cannot find a way to do it without using a ODBC or other older
techniques. Can someone help me with this, below is the code I am
currently attempting to use. I am just not sure where to place the
username and password information or how to pull this from a text file.

import mx.ODBC.Windows
import adodb
import win32com.client

con = win32com.client.Dispatch(r'ADODB.Connection')
DSN = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:/test.mdb;'
con.Open(DSN)
rs = win32com.client.Dispatch(r'ADODB.Recordset')
rs_name = 'testtbl'
rs.Open("SELECT * FROM testtbl", con)

 
Reply With Quote
 
 
 
 
Kent Johnson
Guest
Posts: n/a
 
      10-13-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> In trying to use the adodb module, I have had good success. However I
> need to access a database with a username and password at this time.


I have used a connection string like this to connect to MS SQL Server from adodb:
connStrSQLServer = r"Provider=SQLOLEDB.1; User ID=user; Password=passwd;Initial Catalog=Northwind;Data Source=(local)"

HTH
Kent
 
Reply With Quote
 
 
 
 
LenS
Guest
Posts: n/a
 
      10-13-2005
I have used the following code in ADO:

# The following code creates a connection object,
# assigns the connection string, opens the
# connection object, and then verifies a good
# connection.

oConn = Dispatch('ADODB.Connection')

oConn.ConnectionString = "Provider=SQLOLEDB.1;" +\
"Data Source=servername;" +\
"uid=loginid;" +\
"pwd=password;" +\
"database=databasename"

oConn.Open()
if oConn.State == adStateOpen:
print "Database connection SUCCEEDED"
else:
print "Database connection FAILED"

Hope this helps

 
Reply With Quote
 
LenS
Guest
Posts: n/a
 
      10-13-2005
You also might want to take a look at;

http://www.mayukhbose.com/python/ado/index.php

I found it very helpful

LenS

 
Reply With Quote
 
gt182
Guest
Posts: n/a
 
      10-13-2005
Thank you everyone for your posts. Listed below is the correct code,
solution reached. And to include the username and password you can
simply inter it behind Persist Security devieded off with semicolons.







con = win32com.client.Dispatch(r'ADODB.Connection')
DSN = r'Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\test.mdb;Mode=ReadWrite;Persist Security Info=False'
con.Open(DSN)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ADOdb for Python Mladen Gogala Python 0 06-25-2010 12:59 PM
ADODB Currency type broken in Python win32? Tim Roberts Python 0 04-27-2005 06:48 AM
ADODB.Connection error '800a0e7c' PJ ASP .Net 1 10-30-2003 01:27 PM
COMException Unspecified Error with ADODB and .NET remote users Jim Lacenski ASP .Net 1 10-18-2003 07:51 AM
win32 adodb/mdb; con.execute returns undef and not recordset. Vikas Yadav Perl 0 09-09-2003 09:10 AM



Advertisments