mirror of
https://codeberg.org/prof_x_pvt_ltd/captive.whump.shanti-portal
synced 2024-08-14 22:46:42 +00:00
replacing redis with postgres.
This commit is contained in:
parent
d858f7cb9e
commit
dbbdb29601
2 changed files with 20 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
|||
[pgsql]
|
||||
[postgres]
|
||||
hostname=localhost
|
||||
username=captiveportal
|
||||
password=secret.
|
||||
|
|
|
@ -5,9 +5,24 @@ Database storage backends for client.py.
|
|||
import json
|
||||
from datetime import datetime
|
||||
|
||||
import psycopg2
|
||||
from redis import Redis
|
||||
|
||||
|
||||
class StoragePostgres(object):
|
||||
|
||||
def __init__(self, **kw):
|
||||
config = kw.pop('config')
|
||||
|
||||
self.conn = psycopg2.connect(
|
||||
host=config.get('postgres', 'hostname'),
|
||||
user=config.get('postgres', 'username'),
|
||||
password=config.get('postgres', 'password'),
|
||||
dbname=config.get('postgres', 'database'),
|
||||
port=config.getint('postgres', 'port')
|
||||
)
|
||||
|
||||
|
||||
class DateTimeEncoder(json.JSONEncoder):
|
||||
"""
|
||||
json.JSONEncoder sub-class that converts all datetime objects to
|
||||
|
@ -20,6 +35,9 @@ class DateTimeEncoder(json.JSONEncoder):
|
|||
|
||||
|
||||
class StorageRedis(object):
|
||||
"""
|
||||
Note: Abandoned this storage backend for Postgres.
|
||||
"""
|
||||
|
||||
def __init__(self, **kw):
|
||||
config = kw.pop('config')
|
||||
|
@ -32,4 +50,4 @@ class StorageRedis(object):
|
|||
|
||||
|
||||
def add_client(self, client_id, **kw):
|
||||
pass
|
||||
raise NotImplemented
|
||||
|
|
Loading…
Reference in a new issue