-
-
Notifications
You must be signed in to change notification settings - Fork 317
/
Copy pathExample2.py
76 lines (61 loc) · 2.55 KB
/
Example2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import DBFireDac
# Get the TTable object associated to
# the delphi table displayed on right
# It is done when you click on Execute
T = DBFireDac.T
# Display TableName
print ("TableName: ", T.TableName)
# Display columns
print ("Columns: ")
for i in T.FieldNamesAsTuple():
print (" ", i)
T.CancelRange()
# For each record of the table
for i in T: # <- required ContainerAccess !!!
print ("Rec.", T.RecNo, ":", i)
# Print some fields by their names
print ("Rec.", T.RecNo, ": ", "Company: ", T.FieldByName("Company").Value)
# check state
if not T.State in [DBFireDac.dsEdit, DBFireDac.dsInsert]:
print ("Table is not edited")
# access the table like an array
print ("Index 10; Row 11: ", T[10]) # Row 11 <- required ContainerAccess !!!
print ("Index 10; Row 11 - First field: ", T[10][1]) # second field of row 11 <- required ContainerAccess !!!
# locate a record
if T.Locate( "City;State", ["Largo","FL"], [] ):
print ("Found RecNo:", T.RecNo, " for Locate(Key: 'City;State', Value: [Largo,FL])")
if T.Locate( "Company", "BLUE SPORTS", [DBFireDac.loCaseInsensitive] ):
print ("Found RecNo:", T.RecNo, " for Locate(Key: 'Company', Value: [BLUE SPORTS])")
if T.Locate( "Company", "ISLAND", [DBFireDac.loCaseInsensitive, DBFireDac.loPartialKey] ):
print ("Found RecNo:", T.RecNo, " for Locate(Key: 'Company', Value: [ISLAND])")
# lookup a record
print ("Lookup 'CustNo;Company' for Key: 'City;State', Value: [Largo,FL] -> ", T.Lookup( "City;State", ["Largo","FL"], "CustNo;Company" ))
# define a range
print ("-----------------------------------------------------------")
print ("Names of Indexes:", T.GetIndexNames())
T.IndexName = "SK1_CUSTOMER"
T.SetRange( ["Unisco"], ["Unisco"] )
for i in T:
print ("Rec.", T.RecNo, ":", i)
T.CancelRange()
print ("-----------------------------------------------------------")
# Find a record
if T.FindKey( ['Unisco'] ):
print ("Unisco found !")
else:
print ("Could not find Unisco !")
# Find the nearest record
T.FindNearest( ['Ocean'] )
print ("Find nearest Ocean :", T.FieldsAsTuple())
# Print all doc strings of an instance's methods
def PrintDocOf( inst ):
print ("--------------------- Type ", type(inst).__name__, "---------------------")
if type(inst).__doc__:
print (type(inst).__doc__)
print ("-----------------------------------------------------------")
print ("Documentation:")
print
print ("Module DBFireDac:")
print (DBFireDac.__doc__)
PrintDocOf(T)
print ("-----------------------------------------------------------")