-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
53 lines (43 loc) · 1.68 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from src.populate import DatabasePopulator
from decouple import config
from rich.traceback import install
from rich.console import Console
import data
def configure_database():
"""
Read database configuration from environment variables.
Reads the following environment variables:
- DB_HOST: Database host name or IP address.
- DB_USER: Database username.
- DB_PASSWORD: Database password.
- DB_NAME: Database name.
Returns:
Tuple (str, str, str, str): A tuple containing (host, user, password, database).
"""
# Read database configuration
db_host = config("DB_HOST")
db_user = config("DB_USER")
db_password = config("DB_PASSWORD")
db_database = config("DB_NAME")
return db_host, db_user, db_password, db_database
def main():
install()
console = Console()
try:
db_host, db_user, db_password, db_database = configure_database()
DatabasePopulator(
user=db_user,
password=db_password,
host=db_host,
database=db_database,
rows=data.number_of_fields, # Number of rows to insert
excluded_tables=data.excluded_tables, # List of tables to exclude from insertion
tables_to_fill=data.tables_to_fill, # List of tables to insert data into
graph=data.graph, # Show table relation graph (True/False)
special_fields=data.fields, # Instructions for identifying and filling columns
special_foreign_fields=data.special_foreign_fields, # Instructions for identifying and filling columns
)
except Exception as e:
console.print_exception()
if __name__ == "__main__":
main()