From 7279c2ba6e9ad29a8e635c21d5549b21d7b8c461 Mon Sep 17 00:00:00 2001 From: yvesf Date: Wed, 10 Jun 2009 05:31:26 +0000 Subject: idlecount git-svn-id: http://xapek.org/svn/common/omegle@1097 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd --- db_proxy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'db_proxy.py') 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}) -- cgit v1.2.1