Skip to content

Commit

Permalink
Add docs for scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jerbob authored and jchristgit committed Dec 16, 2023
1 parent 4fab5b1 commit da69709
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
26 changes: 15 additions & 11 deletions scripts/clean_db.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
"""Script for clearing the connected database of all data."""

import os
from os import getenv

import psycopg2

with psycopg2.connect(
user=getenv("SQL_USER"),
password=getenv("SQL_PASSWORD"),
host=getenv("SQL_HOST"),
port=getenv("SQL_PORT"),
database="template1",
) as connection:
connection.set_isolation_level(0)
with connection.cursor() as cursor:
cursor.execute(f"DROP DATABASE {os.getenv('SQL_DATABASE')}")
cursor.execute(f"CREATE DATABASE {os.getenv('SQL_DATABASE')}")

if __name__ == '__main__':
with psycopg2.connect(
user=getenv("SQL_USER"),
password=getenv("SQL_PASSWORD"),
host=getenv("SQL_HOST"),
port=getenv("SQL_PORT"),
database="template1",
) as connection:
connection.set_isolation_level(0)
with connection.cursor() as cursor:
cursor.execute(f"DROP DATABASE {os.getenv('SQL_DATABASE')}")
cursor.execute(f"CREATE DATABASE {os.getenv('SQL_DATABASE')}")
1 change: 1 addition & 0 deletions scripts/fake/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class PostgreSQL:

@classproperty
def dsn(cls) -> str:
"""Return the DSN for connecting to the configured database."""
return f"postgres://{cls.USER}:{cls.PASSWORD}@{cls.HOST}:{cls.PORT}/template1"


Expand Down

0 comments on commit da69709

Please sign in to comment.