2010-02-01 07:29:50 +00:00
|
|
|
import os
|
|
|
|
import sqlite3
|
|
|
|
|
2010-03-01 02:32:41 +00:00
|
|
|
|
2010-03-13 14:02:05 +00:00
|
|
|
def get_db_connection(conn, name=''):
|
2010-02-01 07:29:50 +00:00
|
|
|
"returns an sqlite3 connection to a persistent database"
|
2010-03-13 14:02:05 +00:00
|
|
|
|
|
|
|
if not name:
|
|
|
|
name = '%s.%s.db' % (conn.nick, conn.server)
|
|
|
|
|
|
|
|
filename = os.path.join(bot.persist_dir, name)
|
2010-02-11 23:29:45 +00:00
|
|
|
return sqlite3.connect(filename, timeout=10)
|
2010-02-01 07:29:50 +00:00
|
|
|
|
2010-03-01 02:32:41 +00:00
|
|
|
bot.get_db_connection = get_db_connection
|