airtable-pg-sync


Nameairtable-pg-sync JSON
Version 0.0.47 PyPI version JSON
download
home_pageNone
SummarySync Airtable bases to a Postgres schemas in real time
upload_time2024-07-16 14:29:58
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseCopyright 2023 Benjamin Urwin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Join Us
keywords airtable postgres sync realtime webhook
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Airtable Postgres Sync

The goal of this library is to provide an out-of-the-box solution for replicating
an entire Airtable base in a Postgres schema. There are two modes of operation:

- **One-off-sync**: This mode will replicate the Airtable base in the specified Postgres schema
  and then exit. This is useful for creating snapshots of the base for analysis or for storage as a backup.
- **Perpetual sync**: This mode will replicate the Airtable base in the specified Postgres schema
  and then continue to watch for changes in the base. When a change is detected, the
  change will be applied to the Postgres schema. This is useful for creating a
  replica of the base that can be used for analysis in real time.


This library will produce a Postgres table and view for each of the tables in the specified Airtable base.
The table will take the Airtable table id for its name and the field ids for its column names. The view will have the 
same name as the Airtable table and the column names will be the same as the Airtable column names.
For most analysis use cases it makes sense to use the view as it is more readable, but for applications requiring 
robustness with respect to column name changes the table should be used.


## Installation

To install the library, run the following command:

```bash
pip install airtable-pg-sync
```

## Permissions

To use this library, you will need to create a personal access token in Airtable. This
token will need to have the following scopes:

- data.records:read
- schema.bases:read
- webhook:manage

You will also need to give the Postgres user that you are using read and write access to the schema
you are syncing to.

## Usage

To use the library, you will need to create a config file. The config file defines
all the parameters that are needed to connect to Airtable and Postgres, as well as how
your program will listen for changes. The file must be in YAML format and must contain
the following fields:

```yaml
AIRTABLE_PG_SYNC:
  REDUCED_MEMORY: # boolean, if true will use less memory but will be slower when initially syncing tables
  DB_HOST: # Postgres host
  DB_PORT: # Postgres port
  DB_USER: # Postgres user
  DB_PASSWORD: # Postgres password
  DB_NAME: # Postgres database name
  AIRTABLE_PAT: # Airtable personal access token
  LISTENER_PORT: # The port to listen for change notifications on
  WEBHOOK_URL: # The url that Airtable will send change notifications to
    REPLICATION_NAME_ONE: # Unique dummy identifier for the replication 
        BASE_ID: # Airtable base id to sync
        SCHEMA_NAME: # Postgres schema name
    REPLICATION_NAME_TWO: # Unique dummy identifier for the replication 
        BASE_ID: # Airtable base id to sync
        SCHEMA_NAME: # Postgres schema name
```

The library can be used in two ways:

1. As a command line tool

To trigger a one-time sync, run the following command:

```bash
airtable-pg-sync one-time-sync --config /path/to/config.yml
```

To trigger a perpetual sync, run the following command:

```bash
airtable-pg-sync perpetual-sync --config /path/to/config.yml
```

2. As a python library

To trigger a sync from within a python program, run the following code:

```python
from airtable_pg_sync import Sync

Sync(config_path="/path/to/config.yml", perpetual=True / False).run()
```


## Testing and Deployment

When testing this library for your use case the [ngrok](https://ngrok.com/) service is very useful. It allows you to listen 
for requests sent over the internet to your PC (ie the webhook POST requests).

For deployment, it is recommended that you run the library in an AWS EC2 or ECS type service. 
When using reduced memory mode, an instance with 0.25 vCPU and 0.5 GB of memory will be sufficient.
WHen not using reduced memory mode, the instance size will depend on the size of your data set.

## Bugs, Feature Requests, and Contributions

If you find a bug or have a feature request, please open an issue
on [GitHub](https://github.com/benurwin/airtable_pg_sync/issues).
Any contributions are welcome and appreciated. If you would like to
contribute, please open a pull request on [GitHub](https://github.com/benurwin/airtable_pg_sync/pulls).

### Ideas for contributions:

- Add support for other databases
- Add support for Postgres -> Airtable sync

## License

This library is licensed under the MIT License. See the
[LICENSE](https://github.com/benurwin/airtable_pg_sync/blob/main/LICENSE) file

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "airtable-pg-sync",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "airtable, postgres, sync, realtime, webhook",
    "author": null,
    "author_email": "Benjamin Urwin <benurwin@outlook.com>",
    "download_url": "https://files.pythonhosted.org/packages/92/14/5d68ea9aa101a4488bc5b49944ad354a5662518958b76526ea7c298fa952/airtable_pg_sync-0.0.47.tar.gz",
    "platform": null,
    "description": "# Airtable Postgres Sync\n\nThe goal of this library is to provide an out-of-the-box solution for replicating\nan entire Airtable base in a Postgres schema. There are two modes of operation:\n\n- **One-off-sync**: This mode will replicate the Airtable base in the specified Postgres schema\n  and then exit. This is useful for creating snapshots of the base for analysis or for storage as a backup.\n- **Perpetual sync**: This mode will replicate the Airtable base in the specified Postgres schema\n  and then continue to watch for changes in the base. When a change is detected, the\n  change will be applied to the Postgres schema. This is useful for creating a\n  replica of the base that can be used for analysis in real time.\n\n\nThis library will produce a Postgres table and view for each of the tables in the specified Airtable base.\nThe table will take the Airtable table id for its name and the field ids for its column names. The view will have the \nsame name as the Airtable table and the column names will be the same as the Airtable column names.\nFor most analysis use cases it makes sense to use the view as it is more readable, but for applications requiring \nrobustness with respect to column name changes the table should be used.\n\n\n## Installation\n\nTo install the library, run the following command:\n\n```bash\npip install airtable-pg-sync\n```\n\n## Permissions\n\nTo use this library, you will need to create a personal access token in Airtable. This\ntoken will need to have the following scopes:\n\n- data.records:read\n- schema.bases:read\n- webhook:manage\n\nYou will also need to give the Postgres user that you are using read and write access to the schema\nyou are syncing to.\n\n## Usage\n\nTo use the library, you will need to create a config file. The config file defines\nall the parameters that are needed to connect to Airtable and Postgres, as well as how\nyour program will listen for changes. The file must be in YAML format and must contain\nthe following fields:\n\n```yaml\nAIRTABLE_PG_SYNC:\n  REDUCED_MEMORY: # boolean, if true will use less memory but will be slower when initially syncing tables\n  DB_HOST: # Postgres host\n  DB_PORT: # Postgres port\n  DB_USER: # Postgres user\n  DB_PASSWORD: # Postgres password\n  DB_NAME: # Postgres database name\n  AIRTABLE_PAT: # Airtable personal access token\n  LISTENER_PORT: # The port to listen for change notifications on\n  WEBHOOK_URL: # The url that Airtable will send change notifications to\n    REPLICATION_NAME_ONE: # Unique dummy identifier for the replication \n        BASE_ID: # Airtable base id to sync\n        SCHEMA_NAME: # Postgres schema name\n    REPLICATION_NAME_TWO: # Unique dummy identifier for the replication \n        BASE_ID: # Airtable base id to sync\n        SCHEMA_NAME: # Postgres schema name\n```\n\nThe library can be used in two ways:\n\n1. As a command line tool\n\nTo trigger a one-time sync, run the following command:\n\n```bash\nairtable-pg-sync one-time-sync --config /path/to/config.yml\n```\n\nTo trigger a perpetual sync, run the following command:\n\n```bash\nairtable-pg-sync perpetual-sync --config /path/to/config.yml\n```\n\n2. As a python library\n\nTo trigger a sync from within a python program, run the following code:\n\n```python\nfrom airtable_pg_sync import Sync\n\nSync(config_path=\"/path/to/config.yml\", perpetual=True / False).run()\n```\n\n\n## Testing and Deployment\n\nWhen testing this library for your use case the [ngrok](https://ngrok.com/) service is very useful. It allows you to listen \nfor requests sent over the internet to your PC (ie the webhook POST requests).\n\nFor deployment, it is recommended that you run the library in an AWS EC2 or ECS type service. \nWhen using reduced memory mode, an instance with 0.25 vCPU and 0.5 GB of memory will be sufficient.\nWHen not using reduced memory mode, the instance size will depend on the size of your data set.\n\n## Bugs, Feature Requests, and Contributions\n\nIf you find a bug or have a feature request, please open an issue\non [GitHub](https://github.com/benurwin/airtable_pg_sync/issues).\nAny contributions are welcome and appreciated. If you would like to\ncontribute, please open a pull request on [GitHub](https://github.com/benurwin/airtable_pg_sync/pulls).\n\n### Ideas for contributions:\n\n- Add support for other databases\n- Add support for Postgres -> Airtable sync\n\n## License\n\nThis library is licensed under the MIT License. See the\n[LICENSE](https://github.com/benurwin/airtable_pg_sync/blob/main/LICENSE) file\n",
    "bugtrack_url": null,
    "license": "Copyright 2023 Benjamin Urwin  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u201cSoftware\u201d), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \u201cAS IS\u201d, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  Join Us ",
    "summary": "Sync Airtable bases to a Postgres schemas in real time",
    "version": "0.0.47",
    "project_urls": {
        "Homepage": "https://github.com/benurwin/airtable_pg_sync"
    },
    "split_keywords": [
        "airtable",
        " postgres",
        " sync",
        " realtime",
        " webhook"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ebf32d728fbc926252dc1effeaf4f29bd5e6c32d300b5bc6e34f6faefa454188",
                "md5": "785bb29c7e8d9a798cfa02f4f68b0396",
                "sha256": "fd4cc40d7be1130f57d030b00eba9f6850881e5db8c3aa9059d87f52784314bf"
            },
            "downloads": -1,
            "filename": "airtable_pg_sync-0.0.47-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "785bb29c7e8d9a798cfa02f4f68b0396",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 28805,
            "upload_time": "2024-07-16T14:29:53",
            "upload_time_iso_8601": "2024-07-16T14:29:53.912807Z",
            "url": "https://files.pythonhosted.org/packages/eb/f3/2d728fbc926252dc1effeaf4f29bd5e6c32d300b5bc6e34f6faefa454188/airtable_pg_sync-0.0.47-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "92145d68ea9aa101a4488bc5b49944ad354a5662518958b76526ea7c298fa952",
                "md5": "235c2a6cda022992bd5ba2ce728da690",
                "sha256": "dd381d26c6a048748b7994bda9ce48f5de5df56fd0b41a7b62eaac8b5911c9f6"
            },
            "downloads": -1,
            "filename": "airtable_pg_sync-0.0.47.tar.gz",
            "has_sig": false,
            "md5_digest": "235c2a6cda022992bd5ba2ce728da690",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 22451,
            "upload_time": "2024-07-16T14:29:58",
            "upload_time_iso_8601": "2024-07-16T14:29:58.597711Z",
            "url": "https://files.pythonhosted.org/packages/92/14/5d68ea9aa101a4488bc5b49944ad354a5662518958b76526ea7c298fa952/airtable_pg_sync-0.0.47.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-16 14:29:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "benurwin",
    "github_project": "airtable_pg_sync",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "airtable-pg-sync"
}
        
Elapsed time: 0.26080s