Esempio n. 1
0
 def get_value(self, key_column, key_value, value_column):
     if isinstance(key_value, str):
         key_value = f"('{key_value}')"
     query = f"SELECT {value_column} FROM {self.name} WHERE {key_column} = {key_value}"
     postgres.run_query(self.cursor, query)
     value = postgres.get_list_results(self.cursor)[0]
     return value
Esempio n. 2
0
 def run_query(self, query):
     success = postgres.run_query(self.cursor, query)
     try:
         results = self.cursor.fetchall()
     except Exception:
         return success
     return results
Esempio n. 3
0
def test_run_query_invalid(cursor):
    query = 'SELECT *'
    assert postgres.run_query(cursor, query) is False
Esempio n. 4
0
def test_get_list_results(cursor):
    query = f'SELECT * from {test_table_name}'
    postgres.run_query(cursor, query)
    results = postgres.get_list_results(cursor)
    assert len(results) > 0
Esempio n. 5
0
def test_run_query(cursor):
    query = f'SELECT * FROM {test_table_name}'
    assert postgres.run_query(cursor, query) is True