Skip to content

Commit

Permalink
fix merge conflict and use better approach for overwriting env
Browse files Browse the repository at this point in the history
  • Loading branch information
Mustaballer committed Jun 23, 2023
1 parent 0977859 commit cbee5e8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions openadapt/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,14 @@ def create_db(recording_id, sql, values):
shutil.copyfile(source_file_path, target_file_path)
config.set_db_url(db_fname)

with open(config.ENV_FILE_PATH, "r") as f:
lines = f.readlines()
lines[1] = f"DB_FNAME={db_fname}\n"
with open(config.ENV_FILE_PATH, "w") as f:
f.writelines(lines)
with open(config.ENV_FILE_PATH, "r") as env_file:
env_file_lines = [
f"DB_FNAME={db_fname}\n" if env_file_line.startswith("DB_FNAME") else env_file_line
for env_file_line in env_file.readlines()
]

with open(config.ENV_FILE_PATH, "w") as env_file:
env_file.writelines(env_file_lines)

engine = sa.create_engine(config.DB_URL)
Session = sessionmaker(bind=engine)
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cbee5e8

Please sign in to comment.