mirror of
https://git.wownero.com/lza_menace/wowstash.git
synced 2024-08-15 00:33:15 +00:00
adding simple db class for db operations
This commit is contained in:
parent
9c0638da7a
commit
0d1d3c9506
1 changed files with 22 additions and 0 deletions
22
wowstash/library/db.py
Normal file
22
wowstash/library/db.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from psycopg2 import Error as PGError
|
||||
from psycopg2 import connect as PGConnect
|
||||
from wowstash import config
|
||||
|
||||
|
||||
class Database(object):
|
||||
def __init__(self):
|
||||
self.conn = PGConnect(
|
||||
user=config.DB_USER,
|
||||
password=config.DB_PASS,
|
||||
host=config.DB_HOST,
|
||||
port=config.DB_PORT,
|
||||
database=config.DB_NAME
|
||||
)
|
||||
|
||||
cursor = self.conn.cursor()
|
||||
cursor.execute("SELECT VERSION()")
|
||||
results = cursor.fetchone()
|
||||
if results:
|
||||
self.connected = True
|
||||
else:
|
||||
self.connected = False
|
Loading…
Reference in a new issue