本文整理汇总了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
示例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"))
示例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()
示例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