load user
This commit is contained in:
parent
0dfd3ea31a
commit
1ea4ec5df6
1 changed files with 9 additions and 2 deletions
11
dbmanager.py
11
dbmanager.py
|
@ -1,10 +1,17 @@
|
||||||
import psycopg2
|
import psycopg2
|
||||||
|
import psycopg2.extras
|
||||||
|
|
||||||
|
|
||||||
class DbManager(object):
|
class DbManager(object):
|
||||||
|
|
||||||
def __init__(self,db_uri):
|
def __init__(self,db_uri):
|
||||||
self.db_uri=db_uri
|
self.db_uri=db_uri
|
||||||
self.conn=psycopg2.connect(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
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue