Skip to content

Commit

Permalink
Loader.load: call commit on psycopg con instead of sqla session
Browse files Browse the repository at this point in the history
  • Loading branch information
deeenes committed Oct 16, 2024
1 parent 083e99b commit 2e49164
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions omnipath_metabo/schema/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ def load(self):
insert_resource = insert_resource.on_conflict_do_nothing(index_elements=['name'])
self.session.execute(insert_resource)
ids = collections.defaultdict(set)
row_con = self.con.engine.raw_connection()
raw_con = self.con.engine.raw_connection()

with row_con.cursor() as cursor:
with raw_con.cursor() as cursor:

query = """
INSERT INTO structures (name, smiles) VALUES %s ON CONFLICT (smiles) DO NOTHING
INSERT INTO structures (name, smiles) VALUES %s ON CONFLICT (smiles) DO NOTHING
"""
psycopg2.extras.execute_values(cursor, query, self.resource, page_size = 1000)
"""
Expand All @@ -93,9 +93,11 @@ def load(self):
if i > 1000:
break
"""
self.session.commit()
raw_con.commit()
self.update_mol_column()

return

select_str_ids = text('SELECT id, smiles FROM structures')
strids = {
id[1]: id[0]
Expand Down

0 comments on commit 2e49164

Please sign in to comment.