Commit 12a213cc authored by mouadh's avatar mouadh

fix connection

parent 3cbf5812
...@@ -2,14 +2,14 @@ import psycopg2 as pg ...@@ -2,14 +2,14 @@ import psycopg2 as pg
class MyDB(object): class MyDB(object):
def __init__(self, username='postgres', password='root', db=None): def __init__(self, username='postgres', password='root', db=None,host='localhost'):
if db is None: if db is None:
self.connection = pg.connect( self.connection = pg.connect(
"user={0} password={1}".format(username, password)) "user={0} password={1}".format(username, password))
else: else:
try: try:
self.connection = pg.connect("user={0} password={1} dbname='{2}'". self.connection = pg.connect("user={0} password={1} dbname='{2}' host='{3}'".
format(username, password, db)) format(username, password, db,host))
except: except:
print("can't connect") print("can't connect")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment