8000 `drop_test_database` not compatible with psycopg3 · Issue #1811 · django-extensions/django-extensions · GitHub
[go: up one dir, main page]

Skip to content

drop_test_database not compatible with psycopg3 #1811

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

Closed
danjac opened this issue Apr 5, 2023 · 2 comments · Fixed by #1814 or ryanchen99/django-extensions#2
Closed

drop_test_database not compatible with psycopg3 #1811

danjac opened this issue Apr 5, 2023 · 2 comments · Fixed by #1814 or ryanchen99/django-extensions#2

Comments

@danjac
Copy link
danjac commented Apr 5, 2023

It appears that the drop_test_database command is hardcoded for psycopg2 and will break with psycopg3 (supported on Django 4.2+):

Python: 3.11
Django: 4.2
Postgres: 15.0
psycopg[binary]: 3.18

You have requested to drop all test databases.
This will IRREVERSIBLY DESTROY
ALL data in the database "test_postgres"
and all cloned test databases generated via
the "--parallel" flag (these are sequentially
named "test_postgres_1", "test_postgres_2", etc.).
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes
Traceback (most recent call last):
  File "./manage.py", line 26, in <module>
    main()
  File "./manage.py", line 22, in main
    execute_from_command_line(sys.argv)
  File "my-path/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/my-path/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/my-path/lib/python3.11/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/my-path/lib/python3.11/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/my-path/lib/python3.11/site-packages/django_extensions/management/utils.py", line 62, in inner
    ret = func(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/my-path/lib/python3.11/site-packages/django_extensions/management/commands/drop_test_database.py", line 170, in handle
    import psycopg2 as Database  # NOQA

ModuleNotFoundError: No module named 'psycopg2'
@adi-
Copy link
adi- commented Apr 5, 2023

Same with reset_db.py

@jensenbox
Copy link

Is there a workaround at all?


Traceback (most recent call last):
  File "/app/manage.py", line 29, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django_extensions/management/utils.py", line 62, in inner
    ret = func(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django_extensions/management/commands/reset_db.py", line 144, in handle
    import psycopg2 as Database  # NOQA
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'psycopg2'

Apreche added a commit to Apreche/django-extensions that referenced this issue May 2, 2023
trbs pushed a commit that referenced this issue May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants
0