| 1 |
## Commence COM Testing
|
| 2 |
## Some simple code testing the commence COM layer.
|
| 3 |
## EBorges
|
| 4 |
## 11.26.03
|
| 5 |
|
| 6 |
from win32com.client import Dispatch
|
| 7 |
|
| 8 |
#Initiate the object
|
| 9 |
commenceObj = Dispatch("Commence.DB")
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
#General DB info
|
| 14 |
print commenceObj.Name
|
| 15 |
print commenceObj.Path
|
| 16 |
print commenceObj.Version
|
| 17 |
print commenceObj.VersionExt
|
| 18 |
|
| 19 |
|
| 20 |
#Actuall DB contents
|
| 21 |
#This one is for a view. You would put a 0 first if you wanted to query a catagory. i.e. the "Person" catagory.
|
| 22 |
contacts = c.GetCursor(1,'MWBB Labor Team',0)
|
| 23 |
#Number of records
|
| 24 |
contacts.RowCount
|
| 25 |
#get field info. This one returns the second listing in the roledex
|
| 26 |
test = contacts.GetQueryRowSet(1,0)
|
| 27 |
test.GetRow(0,"/n",0)
|
| 28 |
|
| 29 |
# This section is for catagory
|
| 30 |
#Get a Cursor with all the info (if you wanted to filter it you would use .SetFilter after getting the Cursor
|
| 31 |
todo = commenceObj.GetCursor(0,"To-Do",0)
|
| 32 |
#get a row count
|
| 33 |
items = todo.RowCount
|
| 34 |
#This grabs a row set. One row in the database(Cursor)
|
| 35 |
test = todo.GetQueryRowSet(1,0) #you dont need to increment the first number to go to the next one. You should do a RowCount and just put this exact thing in a for range(RowCount)
|
| 36 |
#get the label (One of many methods once you have a RowSet
|
| 37 |
test2 = test.GetColumnLabel(1,1)#increment the first number to see all the other ones. you can also do a .ColumnCount
|
| 38 |
#get the row value after you figure out the label of the row.
|
| 39 |
test2 = test.GetRowValue(0,12,0) #the middle number is the column
|
| 40 |
|
| 41 |
|
| 42 |
#Some test code
|
| 43 |
>>> todo = commenceObj.GetCursor(0,"To-Do",0)
|
| 44 |
>>> list = []
|
| 45 |
>>> for row in range(todo.RowCount):
|
| 46 |
... currentRow = todo.GetQueryRowSet(1,0)
|
| 47 |
... list.append(currentRow.GetRowValue(0,0,0))
|
| 48 |
...
|
| 49 |
|