dispatch: Cannot load sample data in database with `dispatch database restore --dump-file dispatch-sample-data.dump`

root@0ef891f171ee/-(o_o)-\0ef891f171ee:/usr/local/lib/python3.8/site-packages/dispatch# dispatch database restore --dump-file /root/dispatch-sample-data.dump
Traceback (most recent call last):
  File "/usr/local/bin/dispatch", line 8, in <module>                         
    sys.exit(entrypoint())   
  File "/usr/local/lib/python3.8/site-packages/dispatch/cli.py", line 843, in entrypoint
    dispatch_cli()                                        
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)               
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 782, in main                                          
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/dispatch/cli.py", line 511, in restore_database
    from sh import psql, createdb
ImportError: cannot import name 'psql' from 'sh' (/usr/local/lib/python3.8/site-packages/sh.py)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 20 (9 by maintainers)

Most upvoted comments

okay all working now.

I was dropping the database before, but the issue was my POSTGRES_USER and DATABASE_CREDENTIALS were not set to ‘dispatch’ as the database code was assuming in ‘data/dispatch-sample-data.dump’, even though they were matching. I had my own .env file from before .env.example was updated, so didn’t use defaults in current .env.example

so this is really handy but i think if we can incorporate in the deployment process, or at least make it very easy to do, it would be awesome.

my two cents:

  • incorporate in dispatch-docker/install.sh before upgrade
  • make owner/role whatever POSTGRES_USER or DATABASE_CREDENTIALS is

Thanks again, now i have something to play with