Merge remote-tracking branch 'origin/master'
# Conflicts: # config.sample.json # server.py
This commit is contained in:
commit
a497a0215c
3 changed files with 18 additions and 7 deletions
|
@ -1,9 +1,14 @@
|
||||||
/*
|
/*
|
||||||
create a db_config.json here's a sample
|
create a db_config.json here's
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
"config":{
|
"config": {
|
||||||
"db_params":{"uri":"postgresql://user:password@host:port/dbname"},
|
"db_params": {
|
||||||
"jwt_secret":"Secret for jwt encryption"
|
"uri": "postgresql://user:password@host:port/dbname"
|
||||||
|
},
|
||||||
|
"jwt": {
|
||||||
|
"secret": "secret",
|
||||||
|
"expire_seconds": 3600
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ log=logging.getLogger("rudemaps")
|
||||||
CONFIG={}
|
CONFIG={}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def load_config(config_file="config.json"):
|
def load_config(config_file="config.json"):
|
||||||
global CONFIG
|
global CONFIG
|
||||||
log.debug("loading configuration file")
|
log.debug("loading configuration file")
|
||||||
|
|
Loading…
Reference in a new issue