diff --git a/arkindex/documents/export/__init__.py b/arkindex/documents/export/__init__.py
index b11e8081066888a9fa4b14813ea686f7ced85593..df872fcbc30b74146e275906a9ef44d90987db46 100644
--- a/arkindex/documents/export/__init__.py
+++ b/arkindex/documents/export/__init__.py
@@ -54,7 +54,7 @@ def run_pg_query(query, source_db):
     db = connections[source_db]
 
     # Make sure a connection is open and available for export databases
-    if db != "default" and db.connection is None:
+    if source_db != "default" and db.connection is None:
         db.connect()
 
     with db.create_cursor(name=str(uuid.uuid4())) as pg_cursor: