1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2024-10-06 02:41:11 +01:00

output_processors/postgresql: Group database connection operations

Refactors connection operations into the `connect_to_database`
method.
This commit is contained in:
Marc Bonnici 2019-08-28 11:03:18 +01:00 committed by setrofim
parent e387e3d9b7
commit eeebd010b9

View File

@ -128,8 +128,6 @@ class PostgresqlResultProcessor(OutputProcessor):
'Postgresql Output Processor: {}'.format(import_error_msg))
# N.B. Typecasters are for postgres->python and adapters the opposite
self.connect_to_database()
self.cursor = self.conn.cursor()
self.verify_schema_versions()
# Register the adapters and typecasters for enum types
self.cursor.execute("SELECT NULL::status_enum")
@ -513,6 +511,8 @@ class PostgresqlResultProcessor(OutputProcessor):
raise OutputProcessorError(
"Database error, if the database doesn't exist, " +
"please use 'wa create database' to create the database: {}".format(e))
self.cursor = self.conn.cursor()
self.verify_schema_versions()
def execute_sql_line_by_line(self, sql):
cursor = self.conn.cursor()