16 lines
454 B
Python
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()
|
|
|