@@ -302,10 +302,10 @@ def trigger_pandda_xchem(
302302 db = xchem_visit_dir / "processing/database" / "soakDBDataFile.sqlite"
303303
304304 # Make a copy of the most recent sqlite for reading
305- db_copy = xchem_visit_dir / "processing/database" / "auto_soakDBDataFile.sqlite"
306- if not db_copy .exists () or (db .stat ().st_mtime != db_copy .stat ().st_mtime ):
307- shutil .copy2 (str (db ), str (db_copy ))
308- self .log .info (f"Made a copy of { db } , auto_soakDBDataFile.sqlite" )
305+ # db_copy = xchem_visit_dir / "processing/database" / "auto_soakDBDataFile.sqlite"
306+ # if not db_copy.exists() or (db.stat().st_mtime != db_copy.stat().st_mtime):
307+ # shutil.copy2(str(db), str(db_copy))
308+ # self.log.info(f"Made a copy of {db}, auto_soakDBDataFile.sqlite")
309309
310310 # 1. Trigger when all upstream pipelines & related dimple jobs have finished
311311
@@ -573,21 +573,25 @@ def trigger_pandda_xchem(
573573
574574 # Read XChem SQLite for ligand info
575575 try :
576- conn = sqlite3 .connect (db_copy )
576+ conn = sqlite3 .connect (f"file: { db } ?mode=ro" , uri = True )
577577 df = pd .read_sql_query (
578578 f"SELECT * from mainTable WHERE Puck = '{ code } ' AND PuckPosition = { location } AND CrystalName = '{ dtag } '" ,
579579 conn ,
580580 )
581- conn . close ()
582- except Exception as e :
581+
582+ except sqlite3 . OperationalError as e :
583583 self .log .info (
584- f"Exception whilst reading ligand information from { db_copy } for dtag { dtag } : { e } "
584+ f"Exception whilst reading ligand information from { db } for dtag { dtag } : { e } "
585585 )
586586 return {"success" : True }
587587
588+ finally :
589+ if "conn" in locals ():
590+ conn .close ()
591+
588592 if len (df ) != 1 :
589593 self .log .info (
590- f"Unique row in .sqlite for dcid { dcid } , puck { code } , puck position { location } cannot be found in database { db_copy } , can't continue."
594+ f"Unique row in .sqlite for dcid { dcid } , puck { code } , puck position { location } cannot be found in database { db } , can't continue."
591595 )
592596 return {"success" : True }
593597
@@ -655,7 +659,7 @@ def trigger_pandda_xchem(
655659 "n_datasets" : n_datasets ,
656660 "scaling_id" : scaling_id ,
657661 "comparator_threshold" : comparator_threshold ,
658- "database_path" : str (db_copy ),
662+ "database_path" : str (db ),
659663 }
660664
661665 jp = self .ispyb .mx_processing .get_job_params ()
0 commit comments