@@ -261,6 +261,51 @@ def drop_table(
261261 else :
262262 return f"DROP TABLE { name } "
263263
264+ def try_drop_table (
265+ self ,
266+ cursor : adbc_driver_manager .dbapi .Cursor ,
267+ * ,
268+ table_name : str ,
269+ schema_name : str | None = None ,
270+ catalog_name : str | None = None ,
271+ temporary : bool = False ,
272+ ) -> None :
273+ """
274+ Try to drop a table, ignoring errors if the table does not exist.
275+
276+ Some databases have no way to do DROP IF EXISTS, so this method
277+ attempts to drop the table and catches errors that indicate the
278+ table was not found.
279+
280+ Parameters
281+ ----------
282+ cursor : adbc_driver_manager.dbapi.Cursor
283+ The cursor to execute the query.
284+ table_name : str
285+ The name of the table to drop.
286+ schema_name : str, optional
287+ The schema containing the table (if not given, assume current
288+ schema).
289+ catalog_name : str, optional
290+ The catalog containing the table (if not given, assume current
291+ catalog).
292+ temporary : bool
293+ If True, the table is a temporary table.
294+ """
295+ try :
296+ cursor .execute (
297+ self .drop_table (
298+ table_name = table_name ,
299+ schema_name = schema_name ,
300+ catalog_name = catalog_name ,
301+ temporary = temporary ,
302+ )
303+ )
304+ except adbc_driver_manager .Error as e :
305+ # Some databases have no way to do DROP IF EXISTS
306+ if not self .is_table_not_found (table_name = table_name , error = e ):
307+ raise
308+
264309 @abc .abstractmethod
265310 def is_table_not_found (self , table_name : str | None , error : Exception ) -> bool :
266311 """
0 commit comments