From 1ea4ec5df619e4787a41bc67c328a52488ea0a10 Mon Sep 17 00:00:00 2001 From: andrea Date: Sat, 11 Feb 2017 15:33:48 +0100 Subject: [PATCH] load user --- dbmanager.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dbmanager.py b/dbmanager.py index 034b4c6..9c1f782 100644 --- a/dbmanager.py +++ b/dbmanager.py @@ -1,10 +1,17 @@ import psycopg2 - +import psycopg2.extras class DbManager(object): def __init__(self,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 +