Skip to main content
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Description: # Pgpipeline: automatic postgres pipeline for Scrapy

A Scrapy pipeline module to persist items to a postgres table automatically.


## Quick Start

Here's an example showing automatic item pipeline, with a custom `JSONB` field.

```python
# settings.py
from sqlalchemy.dialects.postgresql import JSONB

ITEM_PIPELINES = {
'pgpipeline.PgPipeline': 300,
}

PG_PIPELINE = {
'connection': 'postgresql://localhost:5432/scrapy_db',
'table_name': 'demo_items',
'pkey': 'item_id',
'ignore_identical': ['item_id', 'job_id'],
'types': {
'some_data': JSONB
},
'onconflict': 'upsert'
}
```

All columns, tables, and indices are automatically created.

* `pkey`: a primary key for this item (other than database-generated `id`)
* `ignore_identical`: these are a set of fields by which we identify duplicates and skip insert.
* `types`: keys specified here will be using the type given, otherwise types are guessed.
* `onconflict`: upsert|ignore|non-null - `ignore` will skip inserting on conflict and `upsert` will update. `non-null` will upsert only values that are not `None` and thus avoid removing existing values.

## Developers

Set up a development environment
```
$ pip install -r requirements.txt
```

### Development

* Dependencies: list them in `requirements.txt`

### Release

* Dependencies: list them in `setup.py` under `install_requires`:

```python
install_requires=['peppercorn'],
```

Then:

```
$ make dist && make release
```

# Contributing

Fork, implement, add tests, pull request, get my everlasting thanks and a respectable place here :).


### Thanks:

To all [Contributors](https://github.com/jondot/pgpipeline/graphs/contributors) - you make this happen, thanks!


# Copyright

Copyright (c) 2017 [Dotan Nahum](http://gplus.to/dotan) [@jondot](http://twitter.com/jondot). See [LICENSE](LICENSE.txt) for further details.

Platform: UNKNOWN

Metadata

Release files for pgpipeline 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pgpipeline 0.4.0
File Size Uploaded
pgpipeline-0.4.0.tar.gz 3.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pgpipeline 0.4.0
File Interpreter ABI Platform
pgpipeline-0.4.0-py2-none-any.whl Python 2 none any Details

Total release size: 9.7 kB

Release files / pgpipeline-0.4.0.tar.gz

Download URL pgpipeline-0.4.0.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
25565288d73b60de8dac179645c82d821d1c9ad82beaf317095cfd46d92b6278
BLAKE2b-256 checksum
How to use checksums
3d4f53a4da647365b17716f1978fe14b30ef56cc865561e2da472a3f4db3d432
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pgpipeline-0.4.0-py2-none-any.whl

Download URL pgpipeline-0.4.0-py2-none-any.whl
Size 6.5 kB
Tags Python 2
SHA-256 checksum
How to use checksums
1bc487f2691e801f692fa625d04dccd0cb8158042fd056ebbfc2b3f7f2cbbe52
BLAKE2b-256 checksum
How to use checksums
13bf457ab9d0957e441e68bdd2ed71d17861dba7a9ab0e6026c506c3ac9d844f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page