-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#470 Initiate standalone script to add PostGIS multigeom table
- Loading branch information
1 parent
76bef28
commit ff8ab86
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
from qgis.core import QgsDataSourceUri, QgsProject | ||
from db_manager.db_plugins.postgis.connector import PostGisDBConnector | ||
from db_manager.db_plugins.postgis.plugin import PostGisDBPlugin | ||
from pprint import pprint | ||
from pathlib import Path | ||
import json | ||
|
||
json_env_path = r"C:\Users\SimonSAMPERE\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\isogeo-plugin-qgis\tests\dev\qgis_console\env.json" | ||
with open(json_env_path, "r", encoding="utf-8") as json_file: | ||
env = json.load(json_file) | ||
|
||
uri = QgsDataSourceUri() | ||
host=env.get("ajout_couche_postgis_multigeom").get("host") | ||
port=env.get("ajout_couche_postgis_multigeom").get("port") | ||
db_name=env.get("ajout_couche_postgis_multigeom").get("db_name") | ||
user=env.get("ajout_couche_postgis_multigeom").get("user") | ||
password=env.get("ajout_couche_postgis_multigeom").get("password") | ||
|
||
uri.setConnection(aHost=host, aPort=port, aDatabase=db_name, aUsername=user, aPassword=password) | ||
|
||
pgis_db_plg = PostGisDBPlugin("AlwaysData_isogeoReader") | ||
c = PostGisDBConnector(uri, pgis_db_plg) | ||
|
||
#tables = c.getTables("test") | ||
#pprint(tables) | ||
#pprint(c.getTablePrivileges("test.ADMIN_EXPRESS_COMMUNE")) | ||
#pprint(c.getTablePrivileges("ign.ADMIN_EXPRESS_EPCI")) | ||
#view = tables[5] | ||
#pprint(c.core_connection.tables()) | ||
#uri.setDataSource(view[2], view[1], view[8]) | ||
#layer = QgsVectorLayer(uri.uri(), "DPTS_NVLL_AQUITAINE", "postgres") | ||
#field_names = [i.name() for i in layer.dataProvider().fields()] | ||
#sorted_field_names = field_names.sort(key=lambda x: ("id" not in x, x)) | ||
#pprint(field_names) | ||
#pprint(sorted_field_names) | ||
#lyr = QgsProject.instance().addMapLayer(layer) |