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

Fixed drop test database command with psycopg 3 #1818

Merged
merged 1 commit into from
May 24, 2023

Conversation

jannh
Copy link
Contributor

@jannh jannh commented May 15, 2023

With the current main branch, when executing drop_test_databaes with only psycopg v3 installed, there is a trace, see below.
This PR fixes the command when psycopg v3 is installed. It is backwards compatible with psycopg2.

Traceback (most recent call last):
File "/home/jannh/git/siam/manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/home/jannh/.virtualenvs/siam/lib/python3.11/site-packages/django/core/management/init.py", line 442, in execute_from_command_line
utility.execute()
File "/home/jannh/.virtualenvs/siam/lib/python3.11/site-packages/django/core/management/init.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/jannh/.virtualenvs/siam/lib/python3.11/site-packages/django/core/management/base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/jannh/.virtualenvs/siam/lib/python3.11/site-packages/django/core/management/base.py", line 458, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jannh/.virtualenvs/siam/lib/python3.11/site-packages/django_extensions/management/utils.py", line 62, in inner
ret = func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jannh/.virtualenvs/siam/lib/python3.11/site-packages/django_extensions/management/commands/drop_test_database.py", line 187, in handle
connection = Database.connect(**conn_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jannh/.virtualenvs/siam/lib/python3.11/site-packages/psycopg/connection.py", line 720, in connect
conninfo = make_conninfo(**params)
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jannh/.virtualenvs/siam/lib/python3.11/site-packages/psycopg/conninfo.py", line 59, in make_conninfo
_parse_conninfo(conninfo)
File "/home/jannh/.virtualenvs/siam/lib/python3.11/site-packages/psycopg/conninfo.py", line 98, in _parse_conninfo
raise e.ProgrammingError(str(ex))
psycopg.ProgrammingError: invalid connection option "database"

@jannh jannh mentioned this pull request May 15, 2023
@gadisauskas
Copy link

A fix for reset_db would be nice

@trbs trbs merged commit 4fc31cb into django-extensions:main May 24, 2023
24 checks passed
@trbs
Copy link
Member

trbs commented May 24, 2023

Thanks !

@jannh
Copy link
Contributor Author

jannh commented May 27, 2023

Created another PR for reset_db, see #1821

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants