1212from commitdb import CommitDB
1313from log .logger import logger
1414
15- DB_CONNECT_STRING = "postgresql://{}:{}@{}:{}/{}" .format (
16- os .getenv ("POSTGRES_USER" , "postgres" ),
17- os .getenv ("POSTGRES_PASSWORD" , "example" ),
18- os .getenv ("POSTGRES_HOST" , "localhost" ),
19- os .getenv ("POSTGRES_PORT" , "5432" ),
20- os .getenv ("POSTGRES_DBNAME" , "postgres" ),
21- ).lower ()
15+ # DB_CONNECT_STRING = "postgresql://{}:{}@{}:{}/{}".format(
16+ # os.getenv("POSTGRES_USER", "postgres"),
17+ # os.getenv("POSTGRES_PASSWORD", "example"),
18+ # os.getenv("POSTGRES_HOST", "localhost"),
19+ # os.getenv("POSTGRES_PORT", "5432"),
20+ # os.getenv("POSTGRES_DBNAME", "postgres"),
21+ # ).lower()
2222
2323
2424class PostgresCommitDB (CommitDB ):
@@ -27,12 +27,14 @@ class PostgresCommitDB(CommitDB):
2727 for PostgreSQL
2828 """
2929
30- def __init__ (self ):
31- self .connect_string = ""
30+ def __init__ (self , user , password , host , port , dbname ):
31+ self .connect_string = "postgresql://{}:{}@{}:{}/{}" .format (
32+ user , password , host , port , dbname
33+ ).lower ()
3234 self .connection = None
3335
34- def connect (self , connect_string = DB_CONNECT_STRING ):
35- self .connection = psycopg2 .connect (connect_string )
36+ def connect (self ):
37+ self .connection = psycopg2 .connect (self . connect_string )
3638
3739 def lookup (self , repository : str , commit_id : str = None ) -> List [Dict [str , Any ]]:
3840 if not self .connection :
0 commit comments