summaryrefslogtreecommitdiff
path: root/db_proxy.py
diff options
context:
space:
mode:
Diffstat (limited to 'db_proxy.py')
-rw-r--r--db_proxy.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/db_proxy.py b/db_proxy.py
index f21b363..9e5273e 100644
--- a/db_proxy.py
+++ b/db_proxy.py
@@ -15,7 +15,7 @@ class DBThread(Thread):
def __init__(self,conn_str):
Thread.__init__(self)
# dbconn = ...("dbname='yvesf' user='dbuser' host='localhost' password='dbpass'")
- self.conn = pyPgSQL.PgSQL.connect(conn_str)
+ self.conn = pyPgSQL.PgSQL.connect(conn_str, client_encoding="utf-8", unicode_results=1)
self.queue = Queue.Queue()
self.running = True
def run(self):
@@ -25,13 +25,13 @@ class DBThread(Thread):
msg = self.queue.get(block=True,timeout=2)
except Queue.Empty:
continue
- logging.getLogger("").debug("Insert %s" % msg)
cur = self.conn.cursor()
sql = """INSERT INTO omegle_messages(send_time,from_ident,to_ident,message)
VALUES (CURRENT_TIMESTAMP, %s, %s, %s)"""
cur.execute(sql,(msg['from_ident'],msg['to_ident'],msg['message']))
cur.close()
self.conn.commit()
+ logging.getLogger("").debug("commit" % msg)
def add_message(self,from_ident,to_ident,message):
self.queue.put_nowait({'from_ident':from_ident,'to_ident':to_ident,'message':message})