当前位置: 首页>>代码示例>>Python>>正文


Python QSqlDatabase.drivers方法代码示例

本文整理汇总了Python中PyQt4.QtSql.QSqlDatabase.drivers方法的典型用法代码示例。如果您正苦于以下问题:Python QSqlDatabase.drivers方法的具体用法?Python QSqlDatabase.drivers怎么用?Python QSqlDatabase.drivers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtSql.QSqlDatabase的用法示例。


在下文中一共展示了QSqlDatabase.drivers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: createDbFactory

# 需要导入模块: from PyQt4.QtSql import QSqlDatabase [as 别名]
# 或者: from PyQt4.QtSql.QSqlDatabase import drivers [as 别名]
 def createDbFactory(self,driverName):
     #TODO Treat none return
     if not ('QPSQL' in QSqlDatabase.drivers()): #Driver wasn't loaded
         QgsMessageLog.logMessage('QT PSQL driver not installed!', 'DSG Tools Plugin', QgsMessageLog.CRITICAL)
         return None
     if not ('QSQLITE' in QSqlDatabase.drivers()): #Driver wasn't loaded
         QgsMessageLog.logMessage('QT QSQLITE driver not installed!', 'DSG Tools Plugin', QgsMessageLog.CRITICAL)
         return None        
     
     if driverName == "QSQLITE":
         return SpatialiteDb()
     if driverName == "QPSQL":
         return PostgisDb()
     else:
         return None
开发者ID:alexdsz,项目名称:DsgTools,代码行数:17,代码来源:dbFactory.py

示例2: __init__

# 需要导入模块: from PyQt4.QtSql import QSqlDatabase [as 别名]
# 或者: from PyQt4.QtSql.QSqlDatabase import drivers [as 别名]
 def __init__(self, parent = None):
     """
     Constructor
     
     @param parent reference to the parent widget (QWidget)
     """
     QWidget.__init__(self, parent)
     self.setupUi(self)
     
     self.table.addAction(self.insertRowAction)
     self.table.addAction(self.deleteRowAction)
     
     if QSqlDatabase.drivers().isEmpty():
         KQMessageBox.information(None,
             self.trUtf8("No database drivers found"),
             self.trUtf8("""This tool requires at least one Qt database driver. """
             """Please check the Qt documentation how to build the """
             """Qt SQL plugins."""))
     
     self.connect(self.connections, SIGNAL("tableActivated(QString)"), 
                  self.on_connections_tableActivated)
     self.connect(self.connections, SIGNAL("schemaRequested(QString)"), 
                  self.on_connections_schemaRequested)
     self.connect(self.connections, SIGNAL("cleared()"), 
                  self.on_connections_cleared)
     
     self.emit(SIGNAL("statusMessage(QString)"), self.trUtf8("Ready"))
开发者ID:usc-bbdl,项目名称:R01_HSC_cadaver_system,代码行数:29,代码来源:SqlBrowserWidget.py

示例3: __init__

# 需要导入模块: from PyQt4.QtSql import QSqlDatabase [as 别名]
# 或者: from PyQt4.QtSql.QSqlDatabase import drivers [as 别名]
 def __init__(self, parent = None):
     """
     Constructor
     """
     QDialog.__init__(self, parent)
     self.setupUi(self)
     
     self.databaseFileCompleter = E4FileCompleter()
     
     self.okButton = self.buttonBox.button(QDialogButtonBox.Ok)
     
     drivers = QSqlDatabase.drivers()
     
     # remove compatibility names
     drivers.removeAll("QMYSQL3")
     drivers.removeAll("QOCI8")
     drivers.removeAll("QODBC3")
     drivers.removeAll("QPSQL7")
     drivers.removeAll("QTDS7")
     
     self.driverCombo.addItems(drivers)
     
     self.__updateDialog()
开发者ID:usc-bbdl,项目名称:R01_HSC_cadaver_system,代码行数:25,代码来源:SqlConnectionDialog.py

示例4: databaseConnection

# 需要导入模块: from PyQt4.QtSql import QSqlDatabase [as 别名]
# 或者: from PyQt4.QtSql.QSqlDatabase import drivers [as 别名]
    def databaseConnection(filename):
        driver = "QSQLITE"
        connectionName = filename + "--" + qtDatabaseConnection.uniqueName()

        if not driver in QSqlDatabase.drivers():
            logger.critical("ABORT, the {0} drive isn't available".format(driver))
            return None

        db = None
        if not QSqlDatabase.contains(connectionName):
            QSqlDatabase.addDatabase(driver, connectionName).setDatabaseName(filename)

        db = QSqlDatabase.database(connectionName, open=False)
        if not db.isOpen():
            db.open()

        if db.isOpen():
            logger.info("returning db connection called: {0}".format(db.connectionName()))
            return qtDatabaseWrapper(db)

        logger.critical("ABORT, failed to open the database for storage - tried to use filename: {0}".format(filename))

        return None
开发者ID:zinedine,项目名称:pyMagic,代码行数:25,代码来源:qt_database_wrapper.py


注:本文中的PyQt4.QtSql.QSqlDatabase.drivers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。