acoustid / mbdata

MusicBrainz SQLAlchemy Models
MIT License
97 stars 23 forks source link

Issue with --create-database argument #62

Open Leiyiliro opened 1 year ago

Leiyiliro commented 1 year ago

I am trying to run the mbslave init --create-database

The code here: https://github.com/acoustid/mbdata/blob/ea0e7e2af55096b221b54f3c1e59154f9c03583b/mbdata/replication.py#L584 seems to try to connect to the "musicbrainz" database before it is created, and I get the error FATAL: database "musicbrainz" does not exist: image

Traceback (most recent call last):
  File "/usr/local/bin/mbslave", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/mbdata/replication.py", line 803, in main
    args.func(config, args)
  File "/usr/local/lib/python3.11/site-packages/mbdata/replication.py", line 625, in mbslave_init_main
    create_database(config)
  File "/usr/local/lib/python3.11/site-packages/mbdata/replication.py", line 583, in create_database
    db = connect_db(config, superuser=True, no_db=True)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/mbdata/replication.py", line 209, in connect_db
    return cfg.connect_db(set_search_path=set_search_path, superuser=superuser, no_db=no_db)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/mbdata/replication.py", line 202, in connect_db
    db = psycopg2.connect(**self.database.create_psycopg2_kwargs(superuser=superuser, no_db=no_db))
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/psycopg2/__init__.py", line 122, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.OperationalError: FATAL:  database "musicbrainz" does not exist