def __init__(self, dsn, name, parent=None, objname=None): QSqlDatabase.__init__(self, 'QPSQL7', name, parent, objname) self.conn = BasicConnection(**dsn) self.setDatabaseName(dsn['dbname']) self.setHostName(dsn['host']) self.dbuser = dsn['user'] self.setUserName(self.dbuser) self.stmt = Statement() self.mcursor = StatementCursor(self.conn)
def __init__(self, dsn, name, parent=None, objname=None): QSqlDatabase.__init__(self, "QPSQL7", name, parent, objname) self.conn = BasicConnection(**dsn) self.setDatabaseName(dsn["dbname"]) self.setHostName(dsn["host"]) self.dbuser = dsn["user"] self.setUserName(self.dbuser) self.stmt = Statement() self.mcursor = StatementCursor(self.conn)
def __init__(self, dsn, name, parent=None, objname=None): deprecated('useless.kdedb.BaseDatabase is deprecated') QSqlDatabase.__init__(self, 'QPSQL7', name, parent, objname) if hasattr(dsn, 'items'): #if dsn is dictionary self.conn = BasicConnection(**dsn) self.setDatabaseName(dsn['dbname']) self.setHostName(dsn['host']) self.dbuser = dsn['user'] else: #else a conn was passed as dsn self.conn = dsn self.setDatabaseName(self.conn.conn.db) self.setHostName(self.conn.conn.host) self.dbuser = self.conn.conn.user self.setUserName(self.dbuser) self.stmt = Statement() self.mcursor = StatementCursor(self.conn)
import sys from qt import QLabel, QApplication from qtsql import QSqlDatabase, QSqlCursor from qtsql import QDataTable, QSqlQuery from paella.base import Error from paella.sqlgen.statement import Statement from paella.profile.base import PaellaConfig dbdriver = 'QPSQL7' cfg = PaellaConfig('database') app = QApplication(sys.argv) db = QSqlDatabase.addDatabase(dbdriver) if db: db.setHostName(cfg['dbhost']) db.setDatabaseName(cfg['dbname']) db.setUserName(cfg['dbusername']) db.open() else: raise Error, 'bad db' s = Statement() cursor = QSqlCursor(None, True, QSqlDatabase.database(dbdriver, True)) #s.table = 'suites' s.table = 'gunny_templates' #query = QSqlQuery(q) #cursor = query print cursor.execQuery(str(s))