@@ -251,30 +251,38 @@ async def query_sql(self, sql: str) -> List[Dict[str, Any]]:
251
251
async def use_database (self , database : str ) -> None :
252
252
"""Switch to a different database."""
253
253
# Use DATABASE keyword for DeltaStream syntax
254
- escaped_db = database if database .startswith ('"' ) and database .endswith ('"' ) else f'"{ database } "'
255
- sql = f'USE DATABASE { escaped_db } '
254
+ escaped_db = (
255
+ database
256
+ if database .startswith ('"' ) and database .endswith ('"' )
257
+ else f'"{ database } "'
258
+ )
259
+ sql = f"USE DATABASE { escaped_db } "
256
260
await self .execute_sql (sql )
257
-
261
+
258
262
# Update the current database in memory
259
263
self ._current_database = database
260
264
261
265
async def use_store (self , store : str ) -> None :
262
266
"""Switch to a different store."""
263
267
# Use STORE keyword for DeltaStream syntax
264
- escaped_store = store if store .startswith ('"' ) and store .endswith ('"' ) else f'"{ store } "'
265
- sql = f'USE STORE { escaped_store } '
268
+ escaped_store = (
269
+ store if store .startswith ('"' ) and store .endswith ('"' ) else f'"{ store } "'
270
+ )
271
+ sql = f"USE STORE { escaped_store } "
266
272
await self .execute_sql (sql )
267
-
273
+
268
274
# Update the current store in memory
269
275
self ._current_store = store
270
276
271
277
async def use_schema (self , schema : str ) -> None :
272
278
"""Switch to a different schema."""
273
279
# Use SCHEMA keyword for DeltaStream syntax
274
- escaped_schema = schema if schema .startswith ('"' ) and schema .endswith ('"' ) else f'"{ schema } "'
275
- sql = f'USE SCHEMA { escaped_schema } '
280
+ escaped_schema = (
281
+ schema if schema .startswith ('"' ) and schema .endswith ('"' ) else f'"{ schema } "'
282
+ )
283
+ sql = f"USE SCHEMA { escaped_schema } "
276
284
await self .execute_sql (sql )
277
-
285
+
278
286
# Update the current schema in memory
279
287
self ._current_schema = schema
280
288
@@ -283,74 +291,74 @@ async def get_current_database(self) -> str:
283
291
# If we have a cached current database, return it
284
292
if self ._current_database :
285
293
return self ._current_database
286
-
294
+
287
295
# Otherwise, query LIST DATABASES to find the default database
288
296
try :
289
297
databases = await self .databases .list ()
290
298
for db in databases :
291
299
# Look for the default database
292
- if hasattr (db , ' is_default' ) and db .is_default :
300
+ if hasattr (db , " is_default" ) and db .is_default :
293
301
self ._current_database = db .name
294
302
return db .name
295
-
303
+
296
304
# If no default found, return the first database if any exist
297
305
if databases :
298
306
self ._current_database = databases [0 ].name
299
307
return databases [0 ].name
300
308
except Exception :
301
309
# If list databases fails, return empty string
302
310
pass
303
-
311
+
304
312
return ""
305
313
306
314
async def get_current_store (self ) -> str :
307
315
"""Get the current store."""
308
316
# If we have a cached current store, return it
309
317
if self ._current_store :
310
318
return self ._current_store
311
-
319
+
312
320
# Otherwise, query LIST STORES to find the default store
313
321
try :
314
322
stores = await self .stores .list ()
315
323
for store in stores :
316
324
# Look for the default store
317
- if hasattr (store , ' is_default' ) and store .is_default :
325
+ if hasattr (store , " is_default" ) and store .is_default :
318
326
self ._current_store = store .name
319
327
return store .name
320
-
328
+
321
329
# If no default found, return the first store if any exist
322
330
if stores :
323
331
self ._current_store = stores [0 ].name
324
332
return stores [0 ].name
325
333
except Exception :
326
334
# If list stores fails, return empty string
327
335
pass
328
-
336
+
329
337
return ""
330
338
331
339
async def get_current_schema (self ) -> str :
332
340
"""Get the current schema."""
333
341
# If we have a cached current schema, return it
334
342
if self ._current_schema :
335
343
return self ._current_schema
336
-
344
+
337
345
# Otherwise, query LIST SCHEMAS to find the default schema
338
346
try :
339
347
schemas = await self .schemas .list ()
340
348
for schema in schemas :
341
349
# Look for the default schema
342
- if hasattr (schema , ' is_default' ) and schema .is_default :
350
+ if hasattr (schema , " is_default" ) and schema .is_default :
343
351
self ._current_schema = schema .name
344
352
return schema .name
345
-
353
+
346
354
# If no default found, return the first schema if any exist
347
355
if schemas :
348
356
self ._current_schema = schemas [0 ].name
349
357
return schemas [0 ].name
350
358
except Exception :
351
359
# If list schemas fails, return empty string
352
360
pass
353
-
361
+
354
362
return ""
355
363
356
364
# Context manager support
0 commit comments