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


Python QSqlDatabase.removeDatabase方法代码示例

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


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

示例1: addConnection

# 需要导入模块: from PyQt4.QtSql import QSqlDatabase [as 别名]
# 或者: from PyQt4.QtSql.QSqlDatabase import removeDatabase [as 别名]
 def addConnection(self, driver, dbName, user, password, host, port):
     """
     Public method to add a database connection.
     
     @param driver name of the Qt database driver (QString)
     @param dbName name of the database (QString)
     @param user user name (QString)
     @param password password (QString)
     @param host host name (QString)
     @param port port number (integer)
     """
     err = QSqlError()
     
     self.__class__.cCount += 1
     db = QSqlDatabase.addDatabase(driver.toUpper(), 
                                   QString("Browser%1").arg(self.__class__.cCount))
     db.setDatabaseName(dbName)
     db.setHostName(host)
     db.setPort(port)
     if not db.open(user, password):
         err = db.lastError()
         db = QSqlDatabase()
         QSqlDatabase.removeDatabase(QString("Browser%1").arg(self.__class__.cCount))
     
     self.connections.refresh()
     
     return err
开发者ID:usc-bbdl,项目名称:R01_HSC_cadaver_system,代码行数:29,代码来源:SqlBrowserWidget.py

示例2: __init__

# 需要导入模块: from PyQt4.QtSql import QSqlDatabase [as 别名]
# 或者: from PyQt4.QtSql.QSqlDatabase import removeDatabase [as 别名]
 def __init__(self):
     '''
     Constructor
     '''
     QSqlDatabase.removeDatabase( 'QMYSQL' )
     self.database = QSqlDatabase.addDatabase( 'QMYSQL' )
     self.database.setDatabaseName( "misimportaciones" )
     self.database.setHostName( "localhost")
     self.database.setUserName( "root" )
     self.database.setPassword( "root" )
开发者ID:joseanm,项目名称:pyqt_billing,代码行数:12,代码来源:database.py

示例3: __del__

# 需要导入模块: from PyQt4.QtSql import QSqlDatabase [as 别名]
# 或者: from PyQt4.QtSql.QSqlDatabase import removeDatabase [as 别名]
 def __del__(self):
     self.db.commit()
     for q in self.query_set:
         logger.debug("cleaning up query: {0}".format(q.lastQuery()))
         q.finish()
         del q
     self.query_set = set()
     logger.debug("cleaning out db connection: {0}".format(self.db.connectionName()))
     self.db.close()
     QSqlDatabase.removeDatabase(self.db.connectionName())
     self.db = None
开发者ID:zinedine,项目名称:pyMagic,代码行数:13,代码来源:qt_database_wrapper.py

示例4: newconfiguration

# 需要导入模块: from PyQt4.QtSql import QSqlDatabase [as 别名]
# 或者: from PyQt4.QtSql.QSqlDatabase import removeDatabase [as 别名]
def newconfiguration( cfg ):
    settings = QSettings()

    dbconfig = dlgDatabaseConfig()
    dbconfig.txtDatabase.setText( settings.value( "%s/DBName" % cfg ).toString() )
    dbconfig.txtServer.setText( settings.value( "%s/DBServer" % cfg ).toString() )
    dbconfig.txtReports.setText( settings.value( "%s/DBReports" % cfg ).toString() )
    dbconfig.txtUser.setText( settings.value( "%s/DBUser" % cfg ).toString() )

    if dbconfig.exec_() == QDialog.Accepted:
        QSqlDatabase.removeDatabase( 'QMYSQL' )
        database = QSqlDatabase.addDatabase( 'QMYSQL' )
        database.setDatabaseName( dbconfig.txtDatabase.text() )
        database.setHostName( dbconfig.txtServer.text() )
        database.setUserName( dbconfig.txtUser.text() )
        database.setPassword( dbconfig.txtPassword.text() )

        #guardar en el archivo de configuracion
        settings.setValue( "%s/DBName" % cfg, dbconfig.txtDatabase.text() )
        settings.setValue( "%s/DBServer" % cfg, dbconfig.txtServer.text() )
        settings.setValue( "%s/DBUser" % cfg, dbconfig.txtUser.text() )
        settings.setValue( "%s/DBPassword" % cfg, dbconfig.txtPassword.text() )
        settings.setValue( "%s/DBReports" % cfg, dbconfig.txtReports.text() )
        reports.Reports.url = dbconfig.txtReports.text()
开发者ID:armonge,项目名称:EsquipulasPy,代码行数:26,代码来源:database.py

示例5: endConnection

# 需要导入模块: from PyQt4.QtSql import QSqlDatabase [as 别名]
# 或者: from PyQt4.QtSql.QSqlDatabase import removeDatabase [as 别名]
 def endConnection():
    DB = Database
    DB.qtpiDB.close()
    DB.qtpiDB = None
    QSqlDatabase.removeDatabase(DB.connection)
开发者ID:rodneyxr,项目名称:USAA-Codeathon-2015,代码行数:7,代码来源:Database.py

示例6: DatabaseInteraction

# 需要导入模块: from PyQt4.QtSql import QSqlDatabase [as 别名]
# 或者: from PyQt4.QtSql.QSqlDatabase import removeDatabase [as 别名]
class DatabaseInteraction(object):
    """Handles all interactions with the database"""
    def __init__(self, test=False):
        if test:
            filename = os.path.join(CONFIG_TEST_DATABASE_PATH, CONFIG_DATABASE_NAME)
        else:
            filename = os.path.join(CONFIG_DATABASE_PATH, CONFIG_DATABASE_NAME)
        self.conn = QSqlDatabase.addDatabase("QSQLITE")
        self.conn.setDatabaseName(filename)
        result = self.conn.open()
        # Check that the db opened successfully, close program if it didn't
        # TODO: handle this better?
        if result == False:
            print "Failed to open database " + filename + \
                " with error: " + self.conn.lastError().text()
            sys.exit(1)

        self.setupModels()

    def setupModels(self):
        # Participant
        self.participantModel = QSqlTableModel(db=self.conn)
        self.participantModel.setTable("participants")
        self.participantModel.setSort(9, Qt.DescendingOrder)
        self.participantModel.select()
        # set headers
        self.participantModel.setHeaderData(0, Qt.Horizontal, "First")
        self.participantModel.setHeaderData(1, Qt.Horizontal, "Last")
        self.participantModel.setHeaderData(2, Qt.Horizontal, "Address")
        self.participantModel.setHeaderData(3, Qt.Horizontal, "Town")
        self.participantModel.setHeaderData(4, Qt.Horizontal, "Postal Code")
        self.participantModel.setHeaderData(5, Qt.Horizontal, "Home Phone")
        self.participantModel.setHeaderData(6, Qt.Horizontal, "Cell Phone")
        self.participantModel.setHeaderData(7, Qt.Horizontal, "Email")
        self.participantModel.setHeaderData(9, Qt.Horizontal, "Date of Birth")
        self.participantModel.setHeaderData(10, Qt.Horizontal, "School Attending")
        self.participantModel.setHeaderData(11, Qt.Horizontal, "Parent")
        self.participantModel.setHeaderData(12, Qt.Horizontal, "School Grade")
        self.participantModel.setHeaderData(13, Qt.Horizontal, "Group Name")
        self.participantModel.setHeaderData(14, Qt.Horizontal, "Group Size")
        self.participantModel.setHeaderData(15, Qt.Horizontal, "Earliest Performance Time")
        self.participantModel.setHeaderData(16, Qt.Horizontal, "Latest Performance Time")
        self.participantModel.setHeaderData(17, Qt.Horizontal, "Participants")  # TODO display names
        self.participantModel.setHeaderData(18, Qt.Horizontal, "Average Age")
        self.participantModel.setHeaderData(19, Qt.Horizontal, "Contact")  # TODO display name
        # TODO display first piece title for groups

        # Teacher
        self.teacherModel = QSqlTableModel(db=self.conn)
        self.teacherModel.setTable("teachers")
        self.teacherModel.setSort(0, Qt.DescendingOrder)
        self.teacherModel.select()
        # set headers
        self.teacherModel.setHeaderData(1, Qt.Horizontal, "First")
        self.teacherModel.setHeaderData(2, Qt.Horizontal, "Last")
        self.teacherModel.setHeaderData(3, Qt.Horizontal, "Address")
        self.teacherModel.setHeaderData(4, Qt.Horizontal, "Town")
        self.teacherModel.setHeaderData(5, Qt.Horizontal, "Postal Code")
        self.teacherModel.setHeaderData(6, Qt.Horizontal, "Daytime Phone")
        self.teacherModel.setHeaderData(7, Qt.Horizontal, "Evening Phone")
        self.teacherModel.setHeaderData(8, Qt.Horizontal, "Email")

        # Entry
        self.entryModel = QSqlTableModel(db=self.conn)
        self.entryModel.setTable("entries")
        self.entryModel.setSort(0, Qt.DescendingOrder)
        self.entryModel.select()
        # set headers
        self.entryModel.setHeaderData(1, Qt.Horizontal, "Participant")  # TODO display name
        self.entryModel.setHeaderData(2, Qt.Horizontal, "Teacher")  # TODO display name
        self.entryModel.setHeaderData(3, Qt.Horizontal, "Discipline")
        self.entryModel.setHeaderData(4, Qt.Horizontal, "Level")
        self.entryModel.setHeaderData(5, Qt.Horizontal, "Class Number")
        self.entryModel.setHeaderData(6, Qt.Horizontal, "Class Name")
        self.entryModel.setHeaderData(7, Qt.Horizontal, "Instrument")
        self.entryModel.setHeaderData(8, Qt.Horizontal, "Years of Instruction")
        self.entryModel.setHeaderData(9, Qt.Horizontal, "Scheduling Requirements")

        # Piece
        self.pieceModel = QSqlTableModel(db=self.conn)
        self.pieceModel.setTable("selections")
        self.pieceModel.setSort(0, Qt.DescendingOrder)
        self.pieceModel.select()
        # set headers
        self.pieceModel.setHeaderData(1, Qt.Horizontal, "Title")
        self.pieceModel.setHeaderData(2, Qt.Horizontal, "Performance Time")
        self.pieceModel.setHeaderData(3, Qt.Horizontal, "Composer/Arranger")
        self.pieceModel.setHeaderData(5, Qt.Horizontal, "Title of Musical")

    def close(self):
        """Clean everything up and close the connection"""
        connName = self.conn.connectionName()
        self.conn.close()
        self.conn = QSqlDatabase()
        self.conn.removeDatabase(connName)

        global dbInteractionInstance 
        dbInteractionInstance = None

    def backupDb(self):
#.........这里部分代码省略.........
开发者ID:diana134,项目名称:afs,代码行数:103,代码来源:databaseInteraction.py

示例7: __del__

# 需要导入模块: from PyQt4.QtSql import QSqlDatabase [as 别名]
# 或者: from PyQt4.QtSql.QSqlDatabase import removeDatabase [as 别名]
 def __del__(self):
     QSqlDatabase.removeDatabase(self.uidConnection)
开发者ID:antwise,项目名称:QgsPostGIS-Viewer,代码行数:4,代码来源:SqlLayer.py


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