mirror of
https://github.com/Xevion/postgres-test.git
synced 2025-12-05 23:15:45 -06:00
Setup main.py logging, seed.main call, add util.py
This commit is contained in:
9
main.py
9
main.py
@@ -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
13
src/util.py
Normal 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))
|
||||
Reference in New Issue
Block a user