Ciao a tutti, Lavorando ad un software che si deve interfacciare sia con sqlite che con postgresql, mi sono studiato il PEP249 [0]. Non sono però riuscito a trovare un modo "standard" per verificare se una tabella esiste o meno nel database... Chiaramente posso definire io una funzione tipo:
def table_exist(cursor, tabname): """Return True if the table exist False otherwise""" try: # sqlite cursor.execute("SELECT name FROM sqlite_master" " WHERE type='table' AND name='%s';" % tabname) except OperationalError: try: # pg cursor.execute("SELECT EXISTS(SELECT * FROM " "information_schema.tables " "WHERE table_name=%s)" % tabname) except OperationalError: return False return True if cursor and cursor.fetchone()[0] else False Siccome mi sembra una funzione abbastanza comune, mi sembra strano che non sia stata definita dallo standard, mi sono perso io qualcosa? Voi come fate di solito? Grazie per le idee. Buona serata Pietro _______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python