-
-
Notifications
You must be signed in to change notification settings - Fork 317
/
Copy pathExample3.py
54 lines (46 loc) · 1.53 KB
/
Example3.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
import DBFireDac
from datetime import datetime
# Get the TTable object associated to
# the delphi table displayed on right
# It is done when you click on Execute
T = DBFireDac.T
# Display columns
print ("Columns: ")
for i in T.FieldNamesAsTuple():
print (" ", i)
# For each record of the table
print ("Company name for each record of table : ")
T.First()
while not T.EOF:
# Print the current record number and the Company
print ("Rec.", T.RecNo, "; Company: ", T.FieldByName("Company").Value)
# Get next record
T.Next()
# check state
if not T.State in [DBFireDac.dsEdit, DBFireDac.dsInsert]:
print ("Table is not edited")
# Find and edit a record
T.IndexName = "SK1_CUSTOMER"
if T.FindKey( ['Unisco'] ):
print ("Unisco found !")
T.Edit()
T.FieldByName('ADDR2').AsString = 'Egal'
T.FieldByName('LASTINVOICEDATE').AsDateTime = datetime.today()
T.Post()
print ("New values for ADDR2='", T.FieldByName('ADDR2').AsString, "'and LASTINVOICEDATE=", T.FieldByName('LASTINVOICEDATE').AsString)
else:
print ("Could not find Unisco !")
# New Company: Append or Delete
if T.FindKey( ['Test-Company'] ):
# Delete record
T.Delete()
print ("New Company 'Test-Company' deleted !")
else:
# New record
T.Append()
T.FieldByName('COMPANY').AsString = 'Test-Company'
T.FieldByName('ADDR1').AsString = 'Marktplatz 1'
T.FieldByName('CITY').AsString = 'Köln'
T.FieldByName('LASTINVOICEDATE').AsDateTime = datetime.today()
T.Post()
print ("New Company 'Test-Company' created !")