Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix to work on default postgres db #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dslr/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ def exec_sql(
global pg_client

if not pg_client:
# We always want to connect to the `postgres` and not the target
# We always want to connect to the `template1` and not the target
# database because none of our operations need to query the target
# database.
pg_client = PGClient(
host=settings.db.host,
port=settings.db.port,
user=settings.db.username,
password=settings.db.password,
dbname="postgres",
dbname="template1",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make more sense to use template0 here? That database should never be modified by users, but template1 is intended to be modified by users to provide per-cluster defaults for new databases. It seems like it might be a valid use case to use dslr to snapshot your template1 DB while experimenting with changes to it locally, whereas that should never be the case for template0.

Relevant docs: https://www.postgresql.org/docs/current/manage-ag-templatedbs.html

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review @bcdickinson . I agree. I can accept this PR if we can change it to use template0.

)

return pg_client.execute(sql, data)