Merge with store
This commit is contained in:
parent
706fe745d3
commit
3ad2766f82
1 changed files with 1185 additions and 0 deletions
20
store/db.py
Normal file
20
store/db.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import psycopg2
|
||||
|
||||
|
||||
def _create_connection():
|
||||
return psycopg2.connect(
|
||||
user="storebackend", host="localhost", port="5432", database="store"
|
||||
)
|
||||
|
||||
|
||||
def execute(query, params):
|
||||
with _create_connection() as connection:
|
||||
cursor = connection.cursor()
|
||||
cursor.execute(query, params)
|
||||
|
||||
|
||||
def get_first(query, params):
|
||||
with _create_connection() as connection:
|
||||
cursor = connection.cursor()
|
||||
cursor.execute(query, params)
|
||||
return cursor.fetchone()
|
||||
Loading…
Reference in a new issue