Skip to content

Commit

Permalink
Merge pull request #2079 from PolicyEngine/1362_remove_seed_method
Browse files Browse the repository at this point in the history
Removed seed method from PolicyEngineDatabase class
  • Loading branch information
anth-volk authored Jan 4, 2025
2 parents 204a25e + fc04f05 commit 5d22d77
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: patch
changes:
removed:
- seed method from PolicyEngineDatabase class
27 changes: 0 additions & 27 deletions policyengine_api/data/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ def __init__(
if initialize:
self.initialize()

self.seed()

def _create_pool(self):
instance_connection_name = (
"policyengine-api:us-central1:policyengine-api-data"
Expand Down Expand Up @@ -101,31 +99,6 @@ def dict_factory(cursor, row):
except Exception as e:
raise e

def seed(self):
"""
Pre-seed the database with records in the relevant folder
"""

folder = REPO / "policyengine_api" / "data" / "seed"

# Recursively loop through all SQL scripts in folder
for dirpath, dirnames, filenames in os.walk(folder):
for filename in filenames:
full_filepath = os.path.join(dirpath, filename)
with open(full_filepath, "r") as file:
try:
full_query = file.read()
queries = full_query.split(";")
for query in queries:
self.query(query)

except Exception as e:
continue
print(
f"Error while seeding database with record {filename}: {e}",
file=sys.stdout,
)

def initialize(self):
"""
Create the database tables.
Expand Down

0 comments on commit 5d22d77

Please sign in to comment.