Connect to Postgres DB - using config data in PostgresConfig
(self, db_name=None, collection_name=None)
| 3046 | self.conn = None |
| 3047 | |
| 3048 | def connect(self, db_name=None, collection_name=None): |
| 3049 | |
| 3050 | """Connect to Postgres DB - using config data in PostgresConfig""" |
| 3051 | |
| 3052 | self.postgres_host = PostgresConfig().get_config("host") |
| 3053 | self.postgres_port = PostgresConfig().get_config("port") |
| 3054 | self.postgres_user_name = PostgresConfig().get_config("user_name") |
| 3055 | self.postgres_pw = PostgresConfig().get_config("pw") |
| 3056 | |
| 3057 | # postgres will use the configured db name |
| 3058 | # if db_name: self.postgres_db_name = db_name |
| 3059 | |
| 3060 | self.postgres_db_name = PostgresConfig().get_config("db_name") |
| 3061 | |
| 3062 | self.conn = psycopg.connect(host=self.postgres_host, port=self.postgres_port, dbname=self.postgres_db_name, |
| 3063 | user=self.postgres_user_name, password=self.postgres_pw) |
| 3064 | |
| 3065 | return self.conn |
| 3066 | |
| 3067 | |
| 3068 | class _SQLiteConnect: |