import psycopg2 import psycopg2.extras class DbManager(object): def __init__(self,db_uri): self.db_uri=db_uri self.conn=psycopg2.connect(db_uri,cursor_factory=psycopg2.extras.DictCursor) def load_user(self,username): with self.conn.cursor() as c: c.execute("select * from users where username=%s",(username,)) user=c.fetchOne() return user