當前位置: 首頁>>代碼示例>>Python>>正文


Python PostGisDBConnector.getTables方法代碼示例

本文整理匯總了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"])))
開發者ID:GeoCat,項目名稱:qgis-webappbuilder-plugin,代碼行數:29,代碼來源:appcreator.py


注:本文中的db_manager.db_plugins.postgis.connector.PostGisDBConnector.getTables方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。