@@ -40,15 +40,20 @@ def main():
4040 test_filter = f"contains(name,'{ tag } ')"
4141 print (f"[INFO] Using tag '{ tag } ' to identify test records" )
4242
43+ select_cols = ["name" , "telephone1" , "websiteurl" , "lastonholdtime" ]
44+
4345 # ── 1. Create records from a DataFrame ────────────────────────
4446 print ("\n " + "-" * 60 )
4547 print ("1. Create records from a DataFrame" )
4648 print ("-" * 60 )
4749
4850 new_accounts = pd .DataFrame ([
49- {"name" : f"Contoso_{ tag } " , "telephone1" : "555-0100" , "websiteurl" : "https://contoso.com" },
50- {"name" : f"Fabrikam_{ tag } " , "telephone1" : "555-0200" , "websiteurl" : "https://fabrikam.com" },
51- {"name" : f"Northwind_{ tag } " , "telephone1" : "555-0300" , "websiteurl" : "https://northwind.com" },
51+ {"name" : f"Contoso_{ tag } " , "telephone1" : "555-0100" , "websiteurl" : "https://contoso.com" ,
52+ "lastonholdtime" : pd .Timestamp ("2024-06-15 10:30:00" )},
53+ {"name" : f"Fabrikam_{ tag } " , "telephone1" : "555-0200" , "websiteurl" : None ,
54+ "lastonholdtime" : None },
55+ {"name" : f"Northwind_{ tag } " , "telephone1" : None , "websiteurl" : "https://northwind.com" ,
56+ "lastonholdtime" : pd .Timestamp ("2024-12-01 08:00:00" )},
5257 ])
5358 print (f" Input DataFrame:\n { new_accounts .to_string (index = False )} \n " )
5459
@@ -63,7 +68,7 @@ def main():
6368 print ("-" * 60 )
6469
6570 page_count = 0
66- for df_page in client .get_dataframe (table , select = [ "name" , "telephone1" ] , filter = test_filter , page_size = 2 ):
71+ for df_page in client .get_dataframe (table , select = select_cols , filter = test_filter , page_size = 2 ):
6772 page_count += 1
6873 print (f" Page { page_count } ({ len (df_page )} records):\n { df_page .to_string (index = False )} " )
6974
@@ -73,7 +78,7 @@ def main():
7378 print ("-" * 60 )
7479
7580 all_records = pd .concat (
76- client .get_dataframe (table , select = [ "name" , "telephone1" ] , filter = test_filter , page_size = 2 ),
81+ client .get_dataframe (table , select = select_cols , filter = test_filter , page_size = 2 ),
7782 ignore_index = True ,
7883 )
7984 print (f"[OK] Got { len (all_records )} total records in one DataFrame" )
@@ -87,7 +92,7 @@ def main():
8792
8893 first_id = new_accounts ["accountid" ].iloc [0 ]
8994 print (f" Fetching record { first_id } ..." )
90- single = client .get_dataframe (table , record_id = first_id , select = [ "name" , "telephone1" ] )
95+ single = client .get_dataframe (table , record_id = first_id , select = select_cols )
9196 print (f"[OK] Single record DataFrame:\n { single .to_string (index = False )} " )
9297
9398 # ── 5. Update records from a DataFrame ────────────────────────
@@ -101,7 +106,7 @@ def main():
101106 print ("[OK] Updated 3 records" )
102107
103108 # Verify the updates with a bulk get
104- verified = next (client .get_dataframe (table , select = [ "name" , "telephone1" ] , filter = test_filter ))
109+ verified = next (client .get_dataframe (table , select = select_cols , filter = test_filter ))
105110 print (f" Verified:\n { verified .to_string (index = False )} " )
106111
107112 # ── 6. Broadcast update (same value to all records) ───────────
@@ -116,7 +121,7 @@ def main():
116121 print ("[OK] Broadcast update complete" )
117122
118123 # Verify all records have the same websiteurl
119- verified = next (client .get_dataframe (table , select = [ "name" , "websiteurl" ] , filter = test_filter ))
124+ verified = next (client .get_dataframe (table , select = select_cols , filter = test_filter ))
120125 print (f" Verified:\n { verified .to_string (index = False )} " )
121126
122127 # ── 7. Delete records by passing a Series of GUIDs ────────────
@@ -129,7 +134,7 @@ def main():
129134 print (f"[OK] Deleted { len (new_accounts )} records" )
130135
131136 # Verify deletions - filter for our tagged records should return 0
132- remaining = list (client .get_dataframe (table , select = [ "name" ] , filter = test_filter ))
137+ remaining = list (client .get_dataframe (table , select = select_cols , filter = test_filter ))
133138 count = sum (len (page ) for page in remaining )
134139 print (f" Verified: { count } test records remaining (expected 0)" )
135140
0 commit comments