https://github.com/adjust/pg_type_template
An extension template for Postgres type
https://github.com/adjust/pg_type_template
adjust-pg-extension
Last synced: 9 months ago
JSON representation
An extension template for Postgres type
- Host: GitHub
- URL: https://github.com/adjust/pg_type_template
- Owner: adjust
- Created: 2021-05-26T15:02:37.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2025-06-25T14:06:28.000Z (12 months ago)
- Last Synced: 2025-06-25T15:21:38.836Z (12 months ago)
- Topics: adjust-pg-extension
- Language: Jinja
- Homepage:
- Size: 41 KB
- Stars: 3
- Watchers: 35
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pg_type_template
An extension template for generating a Postgres type
# Usage
To work with `pg_type_template` it is necessary to prepare a model which will be
used to generate a type extension. This model is passed to the `TypeTemplate`
class instance.
Here is an example of such Python script (`example_type_templ.py`):
```
import pg_type_template
model = {
"ext_name": "example_type",
"ext_version": "0.0.1",
"types": [
{
"type_name": "example_type",
"type_values": [
{ "name": "enum 1", "value": 60 },
{ "name": "enum 2", "value": 120 },
{ "name": "enum 3", "value": 180 },
{ "name": "unknown", "value": 255 },
]
}
],
# optional value defaults "GITHUB_TOKEN"
"github_action_token_name": "GITHUB_TOKEN"
}
templ = pg_type_template.TypeTemplate(model)
templ.render_to_dir(".")
```
To install python package you can use a virtual environment:
```
python3 -m venv venv
source venv/bin/activate
```
After the script is defined run the following command:
```
pip install git+ssh://git@github.com/adjust/pg_type_template.git
python3 example_type_templ.py
```