Jaymon / prom

A PostgreSQL or SQLite orm for Python
MIT License
22 stars 4 forks source link

Don't delete system catalog tables in Postgres #76

Closed viggyfresh closed 5 years ago

viggyfresh commented 5 years ago
Jaymon commented 5 years ago

I'm apprehensive about having this in the core for a few reasons:

Because of the above reasons, my inclination is to not merge this unless we can figure out a bulletproof way to tell the system tables apart from the prom tables.

But since you definitely need this, my proposal would be to override prom's Interface with a custom version, along the lines of:

# custom.py
from prom.interface.postgres import PostgreSQL

class CustomPostgres(PostgresSQL):
    def _delete_table(self, schema, **kwargs):
       table_name = self._normalize_table_name(schema)
       if table_name.startswith("pg_"): return
       super(CustomPostgres, self)._delete_table(schema, **kwargs)

Then you could just modify your PROM_DSN to use your custom interface instead:

custom.CustomPostgres://user:pw@localhost/db"

Hopefully that can get you pointed in the right direction.

viggyfresh commented 5 years ago

Thanks Jay - will look into it.