Skip to content

Commit

Permalink
Database.wipe drops all tables
Browse files Browse the repository at this point in the history
  • Loading branch information
deeenes committed Oct 16, 2024
1 parent 48b4483 commit 1cc75fd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions omnipath_metabo/schema/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def create(con):
Base.metadata.create_all(con.engine)


TABLES = {'structures', 'identifiers', 'resources'}


class Database:

def __init__(self, con):
Expand Down Expand Up @@ -56,6 +59,15 @@ def __del__(self):

del self.con

def wipe(self) -> None:

for tbl in TABLES:

query = text(f'DROP TABLE {tbl}')

self.con.session.execute(query)
self.con.session.commit()


class Loader():

Expand All @@ -67,7 +79,7 @@ def __init__(self, resource, con):


def load(self):

insert_resource = insert(_structure.Resource).values(
name = self.resource.name
)
Expand All @@ -85,7 +97,7 @@ def load(self):
"""
_log("loading insert statments for structures table")
psycopg2.extras.execute_values(cursor, query, self.resource, page_size = 1000)

raw_con.commit()
_log("structures have been inserted, creating mol column")

Expand Down

0 comments on commit 1cc75fd

Please sign in to comment.