Setup main.py logging, seed.main call, add util.py

This commit is contained in:
2023-04-23 14:31:54 -05:00
parent 6c1016d1a2
commit 9ac6e1b796
2 changed files with 21 additions and 1 deletions

View File

@@ -1,8 +1,15 @@
from psycopg2 import connect
from src.seed import main
import logging
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.ERROR)
logger.setLevel(logging.DEBUG)
if __name__ == '__main__':
conn = connect(dbname='railway', user='postgres', password='8h9hxh5YeBwfqTCrxQQb',
host='containers-us-west-174.railway.app', port='7238')
logger.info('Connected to database.')
main(conn)
main(conn, 250, 1000, 500)

13
src/util.py Normal file
View File

@@ -0,0 +1,13 @@
import random
from datetime import datetime, timedelta
def logarithmic_randint(min: int, max: int) -> int:
"""Return a random integer between min and max, inclusive, with a logarithmic distribution."""
# TODO: Implement
return 0
def get_relative_date(min: int, max: int) -> datetime:
"""Return a random date between min and max days ago, inclusive."""
return datetime.now() - timedelta(days=random.randint(min, max))