Skip to main content

PGCronner

PGCronner is a simple and fast Python package written in Rust using PyO3 that helps manage PostgreSQL cron jobs. It lets you take control of your cron jobs by allowing you to add, remove, or list them easily. PGCronner uses a custom table to handle all these operations seamlessly.

The tool takes advantage of the PyO3 library—an extension module that enables interoperability between Python and Rust. This allows for an increased performance and memory safety.

Installation

First of all, you need to ensure that you have Python installed on your system. If you do not, please follow the official guide to get it up and running.

The package can be installed via pip:

pip install pgcronner

Usage

To use the package, you just need to import it into your Python script.

Here is an example of how to create a new pgcron job:

from pgcronner import PGCronner, Job

PG_URI = "postgresql://postgres:postgres@localhost:5432/postgres" 
pgcronner = PGCronner(PG_URI)

# Create a Job using the provided JobBuilder
# my_job = Job("<name>", "<schedule>", "<command>", "<source>")
my_job = Job("testjob", "*/5 * * * *", "SELECT 1;", "source")

# Pass the Job Object
pgcronner.add(job)

# Sync db table with pgcron
# !!! WARNING - DANGER ZONE !!!
# This deletes all jobs with prefix 'pgcronner' in the `cron.job` table and populates it with the jobs in `pgcronner_jobs`
# See below for implementation

pgcronner.sync()

Listing all the jobs:

jobs = pgcronner.all()
for job in jobs:
    print(job)

Retrieve one job:

job = pgcronner.one("<jobname>")

Removing a job:

# The parameter would be the job name you want to delete.
pgcronner.remove(job_name)

Django

In the examples directory there's also an example on how to add this to a Django project.

Documentation

For more detailed instructions and API details, refer to the full documentation at https://pgcronner.readthedocs.io/.

Contributing

We welcome any kind of contribution - reporting issues, suggesting new features, or even writing code. Please make sure to read the CONTRIBUTING.md file before making a pull request.

License

This project is licensed under the MIT License.

Acknowledgments

This Python package has been realized using PyO3 to create a bridge between Rust and Python.


Enjoy the power of managing your PostgreSQL cron jobs with simplicity and ease. Happy PGCronning!

Metadata

Release files for pgcronner 0.1.14

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

Source distribution (sdist)

Source distribution for pgcronner 0.1.14
File Size Uploaded
pgcronner-0.1.14.tar.gz 33.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pgcronner 0.1.14
File Interpreter ABI Platform
pgcronner-0.1.14-cp311-cp311-manylinux_2_34_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ x86-64 Details

Total release size: 1.4 MB

Release files / pgcronner-0.1.14.tar.gz

Download URL pgcronner-0.1.14.tar.gz
Size 33.1 kB
Tags Source
SHA-256 checksum
How to use checksums
54ddf0a037be03721b579805b72f9cbb9bc76cc89da7b4a5bc78094812d63741
BLAKE2b-256 checksum
How to use checksums
464154ee238e8f3cd63a962ddfe1c4f92a9c330cdbaa88117c59254acbc03841
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.3.1

Release files / pgcronner-0.1.14-cp311-cp311-manylinux_2_34_x86_64.whl

Download URL pgcronner-0.1.14-cp311-cp311-manylinux_2_34_x86_64.whl
Size 1.4 MB
Tags CPython 3.11 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
8ab86893139cf6b5a20afc24399813f815fa61639ba8cac85ccca5d6cdebf1b2
BLAKE2b-256 checksum
How to use checksums
f3d568f53282a24b7e0d50931e4bf822b5d3d0981bd76678b209ddada2d29d7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.3.1

Release history Release notifications | RSS feed

This release

0.1.14 This release

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

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