forget about unicode, and just use text_factory str for sqlite to retrieve raw bytes out of text fields without conversions.

This commit is contained in:
Daniel Folkinshteyn 2010-03-17 13:19:07 -04:00
parent 6ceeace44d
commit 629ede010a

View File

@ -72,8 +72,11 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler):
def makeDb(self, filename):
"""Create the database and connect to it."""
if os.path.exists(filename):
return sqlite3.connect(filename)
db = sqlite3.connect(filename)
db.text_factory = str
return db
db = sqlite3.connect(filename)
db.text_factory = str
cursor = db.cursor()
cursor.execute("""CREATE TABLE triggers (
id INTEGER PRIMARY KEY,
@ -115,7 +118,7 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler):
def _runCommandFunction(self, irc, msg, command):
"""Run a command from message, as if command was sent over IRC."""
# need to encode it from unicode, since sqlite stores text as unicode.
tokens = callbacks.tokenize(unicode.encode(command, 'utf8'))
tokens = callbacks.tokenize(command)
try:
self.Proxy(irc.irc, msg, tokens)
except Exception, e: