本文整理汇总了Python中PyQt4.QtSql.QSqlDatabase.hostName方法的典型用法代码示例。如果您正苦于以下问题:Python QSqlDatabase.hostName方法的具体用法?Python QSqlDatabase.hostName怎么用?Python QSqlDatabase.hostName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtSql.QSqlDatabase
的用法示例。
在下文中一共展示了QSqlDatabase.hostName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PostgisDb
# 需要导入模块: from PyQt4.QtSql import QSqlDatabase [as 别名]
# 或者: from PyQt4.QtSql.QSqlDatabase import hostName [as 别名]
#.........这里部分代码省略.........
settings = QSettings()
settings.beginGroup('PostgreSQL/servers/'+name)
host = settings.value('host')
port = settings.value('port')
user = settings.value('username')
password = settings.value('password')
settings.endGroup()
return (host, port, user, password)
def getStructureDict(self):
try:
self.checkAndOpenDb()
except:
return dict()
classDict = dict()
sql = self.gen.getStructure(self.getDatabaseVersion())
query = QSqlQuery(sql, self.db)
while query.next():
className = str(query.value(0))+'.'+str(query.value(1))
fieldName = str(query.value(2))
if str(query.value(0)) == 'complexos' or className.split('_')[-1] in ['p','l','a']:
if className not in classDict.keys():
classDict[className]=dict()
classDict[className][fieldName]=fieldName
if 'geom' in classDict[className].keys():
classDict[className]['geom'] = 'GEOMETRY'
if str(query.value(0)) <> 'complexos' and 'id' in classDict[className].keys():
classDict[className]['id'] = 'OGC_FID'
return classDict
def makeOgrConn(self):
dbName = self.db.databaseName()
dbUser = self.db.userName()
dbHost = self.db.hostName()
dbPass = self.db.password()
dbPort = str(self.db.port())
constring = 'PG: dbname=\''+dbName+'\' user=\''+dbUser+'\' host=\''+dbHost+'\' password=\''+dbPass+'\' port='+dbPort
return constring
def getNotNullDict(self):
try:
self.checkAndOpenDb()
except:
return dict()
if self.getDatabaseVersion() == '2.1.3':
schemaList = ['cb', 'complexos']
elif self.getDatabaseVersion() == 'FTer_2a_Ed':
schemaList = ['pe','ge','ct', 'complexos']
else:
QgsMessageLog.logMessage(self.tr('Operation not defined for this database version!'), "DSG Tools Plugin", QgsMessageLog.CRITICAL)
return None
sql = self.gen.getNotNullFields(schemaList)
query = QSqlQuery(sql, self.db)
notNullDict = dict()
while query.next():
schemaName = str(query.value(0))
className = str(query.value(1))
attName = str(query.value(2))
cl = schemaName+'.'+className
if cl not in notNullDict.keys():
notNullDict[cl] = []
notNullDict[cl].append(attName)
return notNullDict
def getDomainDict(self):
try: