[](https://circleci.com/gh/yohanboniface/psycopg-postgis) [](https://pypi.python.org/pypi/psycopg-postgis) [](https://pypi.python.org/pypi/psycopg-postgis) [](https://pypi.python.org/pypi/psycopg-postgis) [](https://pypi.python.org/pypi/psycopg-postgis)
# psycopg-postgis
PostGIS helpers for psycopg2.
## Install
pip install psycopg-postgis
If you want a compiled version, first install cython:
pip install cython pip install psycopg-postgis
## Usage
You need to register the extension:
> import postgis > postgis.register(mydatabase.get_cursor())
Then you can pass python geometries instance to psycopg:
> cursor.execute(‘INSERT INTO table (geom) VALUES (%s)’, [Point(x=1, y=2, srid=4326)])
And retrieve data as python geometries instances:
> cursor.execute(‘SELECT geom FROM points LIMIT 1’) > geom = cursor.fetchone()[0] > geom <Point POINT(1.0 2.0)>
## Example
> import psycopg2 > from postgis import register, LineString > db = psycopg2.connect(dbname=”test”) > cursor = db.cursor() > register(cursor) > cursor.execute(‘CREATE TABLE IF NOT EXISTS mytable (“geom” geometry(LineString) NOT NULL)’) > cursor.execute(‘INSERT INTO mytable (geom) VALUES (%s)’, [LineString([(1, 2), (3, 4)], srid=4326)]) > cursor.execute(‘SELECT geom FROM mytable LIMIT 1’) > geom = cursor.fetchone()[0] > geom <LineString LINESTRING(1.0 2.0, 3.0 4.0)> > geom[0] <Point POINT(1.0 2.0)> > geom.coords ((1.0, 2.0), (3.0, 4.0)) > geom.geojson {‘coordinates’: ((1.0, 2.0), (3.0, 4.0)), ‘type’: ‘LineString’} > str(geom.geojson) ‘{“type”: “LineString”, “coordinates”: [[1, 2], [3, 4]]}’
Metadata
Release files for psycopg-postgis2 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| psycopg-postgis2-0.0.2.tar.gz | 5.6 kB | Without provenance | Details for psycopg-postgis2-0.0.2.tar.gz |
Release files / psycopg-postgis2-0.0.2.tar.gz
| Download URL | psycopg-postgis2-0.0.2.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d85f501158dc9ef68e541a647a95d3ddc4d23681a6024cebda63b6584b6ee68
|
|
BLAKE2b-256 checksum How to use checksums |
15d15d431a9c924aba279cf017599ba133ea022f1270d01d50e760a222648417
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for psycopg-postgis2 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.