本文整理匯總了Python中db_manager.db_plugins.postgis.connector.PostGisDBConnector.getTables方法的典型用法代碼示例。如果您正苦於以下問題:Python PostGisDBConnector.getTables方法的具體用法?Python PostGisDBConnector.getTables怎麽用?Python PostGisDBConnector.getTables使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類db_manager.db_plugins.postgis.connector.PostGisDBConnector
的用法示例。
在下文中一共展示了PostGisDBConnector.getTables方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: importPostgis
# 需要導入模塊: from db_manager.db_plugins.postgis.connector import PostGisDBConnector [as 別名]
# 或者: from db_manager.db_plugins.postgis.connector.PostGisDBConnector import getTables [as 別名]
def importPostgis(appdef, progress):
progress.setText("Importing into PostGIS")
progress.setProgress(0)
host = appdef["Deploy"]["PostGIS host"]
port = appdef["Deploy"]["PostGIS port"]
username = appdef["Deploy"]["PostGIS username"]
password = appdef["Deploy"]["PostGIS password"]
dbname = appdef["Deploy"]["PostGIS database"]
schema = appdef["Deploy"]["PostGIS schema"]
uri = QgsDataSourceURI()
uri.setConnection(host, port, dbname, username, password)
connector = PostGisDBConnector(uri)
schemas = connector.getSchemas()
schemaExists = schema in [s[1] for s in schemas]
for i, layer in enumerate(appdef["Layers"]):
if layer.method in [METHOD_WFS_POSTGIS, METHOD_WMS_POSTGIS]:
if not schemaExists:
connector.createSchema(schema)
schemaExists = True
tables = connector.getTables(schema=schema)
tablename = safeName(layer.layer.name())
tableExists = tablename in [t[1] for t in tables]
if tableExists:
connector.deleteTable([schema, tablename])
importLayerIntoPostgis(layer.layer, host, port, username, password,
dbname, schema, tablename, appdef["Settings"]["App view CRS"])
progress.setProgress(int(i*100.0/len(appdef["Layers"])))