+ def connect_database(self, dbname):
+ dbargs = {'database': dbname}
+ if self.db_host:
+ dbargs['host'] = self.db_host
+ if self.db_user:
+ dbargs['user'] = self.db_user
+ if self.db_pass:
+ dbargs['password'] = self.db_pass
+ conn = psycopg2.connect(**dbargs)
+ return conn
+