Files
log_analysis/modules/storages/storage.py
T
2023-12-05 00:10:42 +03:00

16 lines
454 B
Python

import psycopg2 as pg
class Storage:
def __init__(self, host, port, database, user, password):
self.connection = pg.connect(host=host, port=port, dbname=database, user=user, password=password)
def do(self, query, should_return=False):
transaction = self.connection.cursor()
transaction.execute(query)
self.connection.commit()
if should_return:
return transaction.fetchall()