diff --git a/acmc/omop.py b/acmc/omop.py index 7bc5dce6252b97caa119c851e64887f05c54efeb..b9761913667b3da763e0d311160e32f3ace12e14 100644 --- a/acmc/omop.py +++ b/acmc/omop.py @@ -312,15 +312,17 @@ def export(map_path, export_path, version, omop_metadata): # Get the list of all tables cur.execute("SELECT name FROM sqlite_master WHERE type='table';") tables = cur.fetchall() # List of tables - + # Export each table to a separate CSV file for table in tables: - table_name = table[0] # Extract table name - df = pd.read_sql_query(f"SELECT * FROM {table_name}", conn) - output_file = f"{table_name}.csv" - output_path = export_path / output_file - df.to_csv(output_path, index=False) # Save as CSV - logger.info(f"Exported {table_name} to {table_name}.csv") + table_name = table[0] + # ignore SQLite's internal system table + if table_name != "sqlite_sequence": + df = pd.read_sql_query(f"SELECT * FROM {table_name}", conn) + output_file = f"{table_name}.csv" + output_path = export_path / output_file + df.to_csv(output_path, index=False) # Save as CSV + logger.info(f"Exported {table_name} to {table_name}.csv") conn.close()