"PostGIS" (Data Connection)
"PostGIS" (Data Connection)
Details
- Use DataConnectionObject to represent data located in a PostGIS database in Wolfram Language.
- Import can be used to retrieve data from a DataConnectionObject.
Properties
| "ConnectionName" | "PostGIS" | |
| "Location" | SQL query given as a string | |
| "Redownload" | whether to rerun the query and overwrite cached results |
| "DatabaseName" | string giving the database to access | |
| "Host" | the host servicing the database |
| "Port" | the server port to access the database |
| "query" | SQL query given as a string |
Account Setting & Authentication
| Automatic | attempt to use saved credentials or give a dialog | |
| "Dialog" | give authentication parameters via a dialog | |
| SystemCredential["key"] | retrieve authentication information from secure storage | |
| SystemCredentialData[…] | stored authentication data | |
| assoc | provide explicit credentials |
| "Username" | username | |
| "Password" | password |
Examples
open all close allBasic Examples (2)
Create a DataConnectionObject to data from a PostgreSQL query:
DataConnectionObject[<|"ConnectionName" -> "PostGIS", "Host" -> "geo.example.com", "Port" -> 5432, "DatabaseName" -> "postgistest", "Location" -> "SELECT * FROM cities WHERE NOT (geom_polygon IS NULL) LIMIT 3"|>, Authentication -> <|"Username" -> "user", "Password" -> "pass"|>]Retrieve the data using Import:
Import@DataConnectionObject[<|"ConnectionName" -> "PostGIS", "Host" -> "geo.example.com", "Port" -> 5432, "DatabaseName" -> "postgistest", "Location" -> "SELECT * FROM cities WHERE NOT (geom_polygon IS NULL) LIMIT 3"|>, Authentication -> <|"Username" -> "user", "Password" -> "pass"|>]Scope (1)
Retrieve data from a PostGIS database:
data = Import[DataConnectionObject[<|"ConnectionName" -> "PostGIS", "Host" -> "geo.example.com", "Port" -> 5432, "DatabaseName" -> "postgistest", "Location" -> "SELECT entity, geog_polygon, st_buffer(geog_polygon, 1000) FROM cities WHERE NOT (geom_polygon IS NULL) limit 10"|>, Authentication -> <|"Username" -> "user", "Password" -> "pass"|>]]Use the polygon data to draw a map of regions around Dresden:
GeoGraphics[{Green, data[[1, 3]], Red, data[[1, 2]]}]See Also
Data Connections: SQLite MySQL MicrosoftSQL Oracle Databricks Snowflake