"PostGIS" (数据连接)
"PostGIS" (数据连接)
更多信息
- 在 Wolfram 语言中,用 DataConnectionObject 来表示位于 PostGIS 数据库中的数据.
- 可用 Import 从 DataConnectionObject 中获取数据.
属性
| "ConnectionName" | "PostGIS" | |
| "Location" | 以字符串形式给出的 SQL 查询 | |
| "Redownload" | 是否重新进行查询并覆盖缓存中的结果 |
| "DatabaseName" | 用于指定要访问的数据库的字符串 | |
| "Host" | 管理数据库的主机 |
| "Port" | 访问数据库的服务器端口 |
| "query" | 以字符串形式给出的 SQL 查询 |
帐户设置与认证
| Automatic | 尝试使用保存的凭据或显示对话框 | |
| "Dialog" | 通过对话框提供认证参数 | |
| SystemCredential["key"] | 从安全存储中获取认证信息 | |
| SystemCredentialData[…] | 保存的认证数据 | |
| assoc | 提供显式凭据 |
| "Username" | 用户名 | |
| "Password" | 密码 |
范例
打开所有单元 关闭所有单元基本范例 (2)
创建一个 DataConnectionObject,连接来自 PostgreSQL 查询中的数据:
DataConnectionObject[<|"ConnectionName" -> "PostGIS", "DatabaseName" -> "dbname", "Host" -> "my.host.com", "Location" -> "SELECT * FROM users"|>, Authentication -> <|"Username" -> "user", "Password" -> "pass"|>]用 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"|>]范围 (1)
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"|>]]GeoGraphics[{Green, data[[1, 3]], Red, data[[1, 2]]}]