2017-02-09 22:56:11 +01:00
|
|
|
import psycopg2
|
2017-02-11 15:33:48 +01:00
|
|
|
import psycopg2.extras
|
2017-02-09 22:56:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
class DbManager(object):
|
|
|
|
|
|
|
|
def __init__(self,db_uri):
|
|
|
|
self.db_uri=db_uri
|
2017-02-11 15:33:48 +01:00
|
|
|
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
|
|
|
|
|
2017-02-09 22:56:11 +01:00
|
|
|
|