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":{
|
||||
"db_params":{"uri":"postgresql://user:password@host:port/dbname"},
|
||||
"jwt_secret":"Secret for jwt encryption"
|
||||
"config": {
|
||||
"db_params": {
|
||||
"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.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
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ log=logging.getLogger("rudemaps")
|
|||
CONFIG={}
|
||||
|
||||
|
||||
|
||||
def load_config(config_file="config.json"):
|
||||
global CONFIG
|
||||
log.debug("loading configuration file")
|
||||
|
|
Loading…
Reference in a new issue