From 6421a3f57e189579643edd02209761f2d5570698 Mon Sep 17 00:00:00 2001
From: Michael Boniface <m.j.boniface@soton.ac.uk>
Date: Thu, 6 Mar 2025 11:15:06 +0000
Subject: [PATCH] (fix) removed export of sqlite_sequence. Closes #45

---
 acmc/omop.py | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/acmc/omop.py b/acmc/omop.py
index 7bc5dce..b976191 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()
 
-- 
GitLab