diff -r 4cf5e664c847 -r 3406d3bf05d4 iro/database.py --- a/iro/database.py Wed Mar 21 19:41:55 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import MySQLdb -import sqlite3 -class Database(object): - def __init__(self,connection): - self.conn=None - self.cursor=None - self.connection=connection - self.testConnection() - - def testConnection(self): - self.connect() - self.disconnect() - - def getConn(self): - return self.conn - - def getCursor(self): - return self.cursor - - def connect(self): - if not self.getConn(): - if (self.connection['type']=='mysql'): - self.conn=MySQLdb.connect( - host = self.connection["host"], - db = self.connection["db"], - user = self.connection["user"], - passwd = self.connection["passwd"], - ) - if (self.connection['type']=='sqlite'): - self.conn=sqlite3.connect(self.connection['path']) - - if not self.getCursor(): - self.cursor = self.conn.cursor() - - def disconnect(self): - if self.getCursor(): - self.cursor.close() - self.cursor=None - if self.getConn(): - self.conn.close() - self.conn=None - -