2929
3030# Simple logging helper
3131def log_call (description ):
32- print (f"\n → { description } " )
32+ print (f"\n -> { description } " )
3333
3434
3535# Define enum for priority picklist
@@ -53,7 +53,7 @@ def backoff(op, *, delays=(0, 2, 5, 10, 20, 20)):
5353 if attempts > 1 :
5454 retry_count = attempts - 1
5555 print (
56- f" ↺ Backoff succeeded after { retry_count } retry(s); waited { total_delay } s total."
56+ f" [INFO] Backoff succeeded after { retry_count } retry(s); waited { total_delay } s total."
5757 )
5858 return result
5959 except Exception as ex : # noqa: BLE001
@@ -63,7 +63,7 @@ def backoff(op, *, delays=(0, 2, 5, 10, 20, 20)):
6363 if attempts :
6464 retry_count = max (attempts - 1 , 0 )
6565 print (
66- f" ⚠ Backoff exhausted after { retry_count } retry(s); waited { total_delay } s total."
66+ f" [WARN] Backoff exhausted after { retry_count } retry(s); waited { total_delay } s total."
6767 )
6868 raise last
6969
@@ -92,7 +92,7 @@ def main():
9292
9393 log_call (f"DataverseClient(base_url='{ base_url } ', credential=...)" )
9494 client = DataverseClient (base_url = base_url , credential = credential )
95- print (f"✓ Connected to: { base_url } " )
95+ print (f"[OK] Connected to: { base_url } " )
9696
9797 # ============================================================================
9898 # 2. TABLE CREATION (METADATA)
@@ -107,7 +107,7 @@ def main():
107107 table_info = backoff (lambda : client .get_table_info (table_name ))
108108
109109 if table_info :
110- print (f"✓ Table already exists: { table_info .get ('table_schema_name' )} " )
110+ print (f"[OK] Table already exists: { table_info .get ('table_schema_name' )} " )
111111 print (f" Logical Name: { table_info .get ('table_logical_name' )} " )
112112 print (f" Entity Set: { table_info .get ('entity_set_name' )} " )
113113 else :
@@ -120,7 +120,7 @@ def main():
120120 "new_Priority" : Priority ,
121121 }
122122 table_info = backoff (lambda : client .create_table (table_name , columns ))
123- print (f"✓ Created table: { table_info .get ('table_schema_name' )} " )
123+ print (f"[OK] Created table: { table_info .get ('table_schema_name' )} " )
124124 print (f" Columns created: { ', ' .join (table_info .get ('columns_created' , []))} " )
125125
126126 # ============================================================================
@@ -140,7 +140,7 @@ def main():
140140 "new_Priority" : Priority .MEDIUM ,
141141 }
142142 id1 = backoff (lambda : client .create (table_name , single_record ))[0 ]
143- print (f"✓ Created single record: { id1 } " )
143+ print (f"[OK] Created single record: { id1 } " )
144144
145145 # Multiple create
146146 log_call (f"client.create('{ table_name } ', [{{...}}, {{...}}, {{...}}])" )
@@ -168,7 +168,7 @@ def main():
168168 },
169169 ]
170170 ids = backoff (lambda : client .create (table_name , multiple_records ))
171- print (f"✓ Created { len (ids )} records: { ids } " )
171+ print (f"[OK] Created { len (ids )} records: { ids } " )
172172
173173 # ============================================================================
174174 # 4. READ OPERATIONS
@@ -180,7 +180,7 @@ def main():
180180 # Single read by ID
181181 log_call (f"client.get('{ table_name } ', '{ id1 } ')" )
182182 record = backoff (lambda : client .get (table_name , id1 ))
183- print ("✓ Retrieved single record:" )
183+ print ("[OK] Retrieved single record:" )
184184 print (
185185 json .dumps (
186186 {
@@ -202,7 +202,7 @@ def main():
202202 records_iterator = backoff (lambda : client .get (table_name , filter = "new_quantity gt 5" ))
203203 for page in records_iterator :
204204 all_records .extend (page )
205- print (f"✓ Found { len (all_records )} records with new_quantity > 5" )
205+ print (f"[OK] Found { len (all_records )} records with new_quantity > 5" )
206206 for rec in all_records :
207207 print (f" - new_Title='{ rec .get ('new_title' )} ', new_Quantity={ rec .get ('new_quantity' )} " )
208208
@@ -217,12 +217,12 @@ def main():
217217 log_call (f"client.update('{ table_name } ', '{ id1 } ', {{...}})" )
218218 backoff (lambda : client .update (table_name , id1 , {"new_Quantity" : 100 }))
219219 updated = backoff (lambda : client .get (table_name , id1 ))
220- print (f"✓ Updated single record new_Quantity: { updated .get ('new_quantity' )} " )
220+ print (f"[OK] Updated single record new_Quantity: { updated .get ('new_quantity' )} " )
221221
222222 # Multiple update (broadcast same change)
223223 log_call (f"client.update('{ table_name } ', [{ len (ids )} IDs], {{...}})" )
224224 backoff (lambda : client .update (table_name , ids , {"new_Completed" : True }))
225- print (f"✓ Updated { len (ids )} records to new_Completed=True" )
225+ print (f"[OK] Updated { len (ids )} records to new_Completed=True" )
226226
227227 # ============================================================================
228228 # 6. PAGING DEMO
@@ -244,7 +244,7 @@ def main():
244244 for i in range (1 , 21 )
245245 ]
246246 paging_ids = backoff (lambda : client .create (table_name , paging_records ))
247- print (f"✓ Created { len (paging_ids )} records for paging demo" )
247+ print (f"[OK] Created { len (paging_ids )} records for paging demo" )
248248
249249 # Query with paging
250250 log_call (f"client.get('{ table_name } ', page_size=5)" )
@@ -265,11 +265,11 @@ def main():
265265 sql = f"SELECT new_title, new_quantity FROM new_walkthroughdemo WHERE new_completed = 1"
266266 try :
267267 results = backoff (lambda : client .query_sql (sql ))
268- print (f"✓ SQL query returned { len (results )} completed records:" )
268+ print (f"[OK] SQL query returned { len (results )} completed records:" )
269269 for result in results [:5 ]: # Show first 5
270270 print (f" - new_Title='{ result .get ('new_title' )} ', new_Quantity={ result .get ('new_quantity' )} " )
271271 except Exception as e :
272- print (f"⚠ SQL query failed (known server-side bug): { str (e )} " )
272+ print (f"[WARN] SQL query failed (known server-side bug): { str (e )} " )
273273
274274 # ============================================================================
275275 # 8. PICKLIST LABEL CONVERSION
@@ -288,7 +288,7 @@ def main():
288288 }
289289 label_id = backoff (lambda : client .create (table_name , label_record ))[0 ]
290290 retrieved = backoff (lambda : client .get (table_name , label_id ))
291- print (f"✓ Created record with string label 'High' for new_Priority" )
291+ print (f"[OK] Created record with string label 'High' for new_Priority" )
292292 print (f" new_Priority stored as integer: { retrieved .get ('new_priority' )} " )
293293 print (f" new_Priority@FormattedValue: { retrieved .get ('new_priority@OData.Community.Display.V1.FormattedValue' )} " )
294294
@@ -301,12 +301,12 @@ def main():
301301
302302 log_call (f"client.create_columns('{ table_name } ', {{'new_Notes': 'string'}})" )
303303 created_cols = backoff (lambda : client .create_columns (table_name , {"new_Notes" : "string" }))
304- print (f"✓ Added column: { created_cols [0 ]} " )
304+ print (f"[OK] Added column: { created_cols [0 ]} " )
305305
306306 # Delete the column we just added
307307 log_call (f"client.delete_columns('{ table_name } ', ['new_Notes'])" )
308308 backoff (lambda : client .delete_columns (table_name , ["new_Notes" ]))
309- print (f"✓ Deleted column: new_Notes" )
309+ print (f"[OK] Deleted column: new_Notes" )
310310
311311 # ============================================================================
312312 # 10. DELETE OPERATIONS
@@ -318,12 +318,12 @@ def main():
318318 # Single delete
319319 log_call (f"client.delete('{ table_name } ', '{ id1 } ')" )
320320 backoff (lambda : client .delete (table_name , id1 ))
321- print (f"✓ Deleted single record: { id1 } " )
321+ print (f"[OK] Deleted single record: { id1 } " )
322322
323323 # Multiple delete (delete the paging demo records)
324324 log_call (f"client.delete('{ table_name } ', [{ len (paging_ids )} IDs])" )
325325 job_id = backoff (lambda : client .delete (table_name , paging_ids ))
326- print (f"✓ Bulk delete job started: { job_id } " )
326+ print (f"[OK] Bulk delete job started: { job_id } " )
327327 print (f" (Deleting { len (paging_ids )} paging demo records)" )
328328
329329 # ============================================================================
@@ -336,11 +336,11 @@ def main():
336336 log_call (f"client.delete_table('{ table_name } ')" )
337337 try :
338338 backoff (lambda : client .delete_table (table_name ))
339- print (f"✓ Deleted table: { table_name } " )
339+ print (f"[OK] Deleted table: { table_name } " )
340340 except Exception as ex : # noqa: BLE001
341341 code = getattr (getattr (ex , "response" , None ), "status_code" , None )
342342 if (isinstance (ex , (requests .exceptions .HTTPError , MetadataError )) and code == 404 ):
343- print (f"✓ Table removed: { table_name } " )
343+ print (f"[OK] Table removed: { table_name } " )
344344 else :
345345 raise
346346
@@ -351,16 +351,16 @@ def main():
351351 print ("Walkthrough Complete!" )
352352 print ("=" * 80 )
353353 print ("\n Demonstrated operations:" )
354- print (" ✓ Table creation with multiple column types" )
355- print (" ✓ Single and multiple record creation" )
356- print (" ✓ Reading records by ID and with filters" )
357- print (" ✓ Single and multiple record updates" )
358- print (" ✓ Paging through large result sets" )
359- print (" ✓ SQL queries" )
360- print (" ✓ Picklist label-to-value conversion" )
361- print (" ✓ Column management" )
362- print (" ✓ Single and bulk delete operations" )
363- print (" ✓ Table cleanup" )
354+ print (" [OK] Table creation with multiple column types" )
355+ print (" [OK] Single and multiple record creation" )
356+ print (" [OK] Reading records by ID and with filters" )
357+ print (" [OK] Single and multiple record updates" )
358+ print (" [OK] Paging through large result sets" )
359+ print (" [OK] SQL queries" )
360+ print (" [OK] Picklist label-to-value conversion" )
361+ print (" [OK] Column management" )
362+ print (" [OK] Single and bulk delete operations" )
363+ print (" [OK] Table cleanup" )
364364 print ("=" * 80 )
365365
366366
0 commit comments