473,408 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

ADO with Python

Is their anybody with xperience in using the both and can provide me with
some xamples.

Thx a lot
Ralf
Oct 16 '06 #1
3 1579
hg
Ralf wrote:
Is their anybody with xperience in using the both and can provide me with
some xamples.

Thx a lot
Ralf

I suggest you buy the book from Mark Hammond

hg
ex (major cut and paste):

#************************************************* *******************
def Get_User_Info_From_DB(self, p_user_id):
try:
#l_query = 'Select Groups.GR_AccessDate from Groups,Members
where Members.GroupId = Groups.GR_GroupId and Members.MemberId = %s;' %
p_user_id
l_query = 'SELECT
Firstname,Lastname,GR_ExpirationDate,GR_AccessDate ,GR_CurrentBal,MemberType,MemberDues
FROM MemberTypes,Members,Groups Where (Groups.GR_GroupId =
Members.GroupId) and (MemberTypes.MemberTypeID =
Groups.GR_MembershipType) and (MemberId = %s);' % p_user_id
l_conn = win32com.client.Dispatch(r'ADODB.Connection')
l_DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE='+self.__m_database + ';'
l_conn.Open(l_DSN)
l_recordset = win32com.client.Dispatch(r'ADODB.Recordset')
l_recordset.Open(l_query, l_conn, 1, 3)
l_found_date = False
try:
l_recordset.MoveFirst()
l_exp_date =
l_recordset.Fields.Item('GR_ExpirationDate').Value
l_access_date =
l_recordset.Fields.Item('GR_AccessDate').Value

l_last_name = l_recordset.Fields.Item('Lastname').Value
l_first_name = l_recordset.Fields.Item('Firstname').Value
l_membership_type =
l_recordset.Fields.Item('MemberType').Value
#print 'HERE ', l_recordset.Fields.Item('MemberType').Value
l_val = l_recordset.Fields.Item('MemberDues').Value

l_dues_amount = '%.02f' % (float(l_val[1])/10000.0)
if None == l_access_date:
self.__m_log.Log( ('DATE IS NOT AVAILABLE FOR USER
ID %s' % p_user_id) )
else:
l_found_date = True
self.__m_log.Log( ('FOUND NEW DATE IN DATABASE FOR
USER ID %s: %s' % (p_user_id, l_access_date)) )
except:
self.__m_log.Log( ( 'GET DATE QUERY FAILED ON USER ID
%s' % p_user_id) )
self.__m_log.Log(traceback.format_exc())
l_conn.Close()

if False == l_found_date:
return None

#print 'IN GET: ACCESS ', l_access_date.Format()
#print 'IN GET: EXP', l_exp_date.Format()
return ( l_exp_date.Format(),l_access_date.Format(),
l_last_name, l_first_name, l_membership_type, l_dues_amount)
except:
self.__m_log.Log(traceback.format_exc())
try:
l_conn.Close()
except:
self.__m_log.Log('Could not close database connection on
retrieval')
self.__m_log.Log(traceback.format_exc())
pass
self.__m_log.Log( ('Fatal error retrieving date from
database for user id %s ' % p_user_id))
return None
Oct 16 '06 #2
Ralf wrote:
Is their anybody with xperience in using the both and can provide me with
some xamples.
Googling for python ado returns this simple tutorial
http://www.markcarter.me.uk/computing/python/ado.html

COM access in Python is straight forward with win32all.

Oct 16 '06 #3

Ralf wrote:
Is their anybody with xperience in using the both and can provide me with
some xamples.

Thx a lot
Ralf
I found the tutorial on this site helpful.

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

Oct 17 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.