Commit 0d77a1c9 authored by mouadh's avatar mouadh

change to sqlalchemy

parent 71fe3e64
import psycopg2 as pg # import psycopg2 as pg
from sqlalchemy import create_engine from sqlalchemy import create_engine
# postgres connection # postgres connection
...@@ -29,8 +29,8 @@ class MyDB(object): ...@@ -29,8 +29,8 @@ class MyDB(object):
if db is None: if db is None:
# first i want to show all databases to user (in excel) # first i want to show all databases to user (in excel)
self.engine = pg.connect("user={0} password={1} host='{2}'". # self.engine = pg.connect("user={0} password={1} host='{2}'".
format(username, password, host)) # format(username, password, host))
self.engine = create_engine('postgresql+psycopg2://{0}:{1}@{3}:{4}/{2}'.format( self.engine = create_engine('postgresql+psycopg2://{0}:{1}@{3}:{4}/{2}'.format(
username, password, 'postgres', host, port)) username, password, 'postgres', host, port))
......
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