Is it possible to change the database schema or table names used by Prodigy?

solved
usage
database
(Philipp Dowling) #1

I’m connecting Prodigy to an existing Postgres cluster, and I’d like to be able to access the annotations created by users in other parts of our system, ideally in conjunction with other tables that already exist for joins, etc. Currently, the table names used by prodigy (dataset, example, link as I understand) are not yet used, but to be on the safe side I’d like to give Prodigy its own namespace, or somehow add a prefix to the table names (in case we ever need those table names to mean something else). Is there any way to do this?

0 Likes

(Ines Montani) #2

The source of the database model (using peewee) is included with Prodigy in components/db.py, so you can check out how it is set up there. For 100% flexibility, you can also implement your own custom Database class – see here for more details:

As long as the database methods exist and do the right thing, it’s then fully up to you how you implement the logic and how the data is stored or retrieved.

0 Likes

(Philipp Dowling) #3

Thanks @ines - I ended up finding a simple solution, it’s possible to set a default schema using the search_path setting:

_db = PostgresqlExtDatabase(
        params["database"],
        user=params["user"],
        password=params["password"],
        host=params["host"],
        options='-c search_path="prodigy"'  # use schema to separate data from core app
    )

Tables are then created as prodigy.dataset, etc.

1 Like