Incompatibility with Django 3.1
Hi!
django-pgcli doesn't seem to be compatible with Django 3.1. Here's the issue I encountered:
🚂 pipenv run ./manage.py dbshell
Traceback (most recent call last):
File "./manage.py", line 20, in <module>
execute_from_command_line(sys.argv)
File "/Users/jrheard/.local/share/virtualenvs/djscoots-zK00EcLC-/Users/jrheard/.pyenv/shims/python/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/Users/jrheard/.local/share/virtualenvs/djscoots-zK00EcLC-/Users/jrheard/.pyenv/shims/python/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/jrheard/.local/share/virtualenvs/djscoots-zK00EcLC-/Users/jrheard/.pyenv/shims/python/lib/python3.7/site-packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/jrheard/.local/share/virtualenvs/djscoots-zK00EcLC-/Users/jrheard/.pyenv/shims/python/lib/python3.7/site-packages/django/core/management/base.py", line 371, in execute
output = self.handle(*args, **options)
File "/Users/jrheard/.local/share/virtualenvs/djscoots-zK00EcLC-/Users/jrheard/.pyenv/shims/python/lib/python3.7/site-packages/django/core/management/commands/dbshell.py", line 26, in handle
connection.client.runshell(options['parameters'])
TypeError: runshell() takes 1 positional argument but 2 were given
I think that this is related to https://github.com/django/django/commit/5b884d45ac5b76234eca614d90c83b347294c332 , a change made in Django 3.1 that modifies the signature of the .runshell() method.
I note that in that Django commit linked above, .runshell() was updated to take args self, parameters, but in https://github.com/ashchristopher/django-pgcli/blob/master/django_pgcli/init.py , django-pgcli's .runshell() takes args self.
That's about as deeply as I've looked into this issue - I'm not clear on the exact semantics of this parameters argument, and it's not immediately clear to me what django-pgcli should do with that argument. The main thing that I'm clear on is that the current release version of django-pgcli isn't compatible with Django 3.1 - hopefully it's an easy fix! 🙏
Thanks for making this library! :)
This worked for me:
class PgCLIDatabaseClient(DatabaseClient):
executable_name = 'pgcli'
def runshell(self, parameters):
PgCLIDatabaseClient.runshell_db(self.connection.get_connection_params(), parameters=parameters)
For anyone who makes use of https://github.com/django-extensions/django-extensions in their project, I found it easier to just run:
pgcli $(./manage.py sqldsn --quiet --style=uri)
This should hopefully fix it if it gets released in an updated version: https://github.com/ashchristopher/django-pgcli/pull/20
Hi any chance it would be possible to merge https://github.com/ashchristopher/django-pgcli/pull/20 and release an updated version? Thank you!!!