Skip to content

Instantly share code, notes, and snippets.

@ferbncode
Created July 7, 2017 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ferbncode/ef110d17be1684eeb16be1aad5bc715c to your computer and use it in GitHub Desktop.
Save ferbncode/ef110d17be1684eeb16be1aad5bc715c to your computer and use it in GitHub Desktop.
Build fails
Error Message
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not translate host name "musicbrainz_db" to address: Name or service not known
Stacktrace
self = Engine(postgresql://musicbrainz:***@musicbrainz_db:5432/musicbrainz_db)
fn = <bound method Pool.connect of <sqlalchemy.pool.NullPool object at 0x7f48e37ff4a8>>
connection = None
def _wrap_pool_connect(self, fn, connection):
dialect = self.dialect
try:
> return fn()
/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py:2147:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <sqlalchemy.pool.NullPool object at 0x7f48e37ff4a8>
def connect(self):
"""Return a DBAPI connection from the pool.
The connection is instrumented such that when its
``close()`` method is called, the connection will be returned to
the pool.
"""
if not self._use_threadlocal:
> return _ConnectionFairy._checkout(self)
/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py:387:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'sqlalchemy.pool._ConnectionFairy'>
pool = <sqlalchemy.pool.NullPool object at 0x7f48e37ff4a8>, threadconns = None
fairy = None
@classmethod
def _checkout(cls, pool, threadconns=None, fairy=None):
if not fairy:
> fairy = _ConnectionRecord.checkout(pool)
/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py:766:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'sqlalchemy.pool._ConnectionRecord'>
pool = <sqlalchemy.pool.NullPool object at 0x7f48e37ff4a8>
@classmethod
def checkout(cls, pool):
> rec = pool._do_get()
/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py:516:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <sqlalchemy.pool.NullPool object at 0x7f48e37ff4a8>
def _do_get(self):
> return self._create_connection()
/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py:1229:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <sqlalchemy.pool.NullPool object at 0x7f48e37ff4a8>
def _create_connection(self):
"""Called by subclasses to create a new ConnectionRecord."""
> return _ConnectionRecord(self)
/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <sqlalchemy.pool._ConnectionRecord object at 0x7f48e26669b0>
pool = <sqlalchemy.pool.NullPool object at 0x7f48e37ff4a8>, connect = True
def __init__(self, pool, connect=True):
self.__pool = pool
if connect:
> self.__connect(first_connect_check=True)
/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py:461:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <sqlalchemy.pool._ConnectionRecord object at 0x7f48e26669b0>
first_connect_check = True
def __connect(self, first_connect_check=False):
pool = self.__pool
# ensure any existing connection is removed, so that if
# creator fails, this attribute stays None
self.connection = None
try:
self.starttime = time.time()
> connection = pool._invoke_creator(self)
/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py:651:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
connection_record = <sqlalchemy.pool._ConnectionRecord object at 0x7f48e26669b0>
def connect(connection_record=None):
if dialect._has_events:
for fn in dialect.dispatch.do_connect:
connection = fn(
dialect, connection_record, cargs, cparams)
if connection is not None:
return connection
> return dialect.connect(*cargs, **cparams)
/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py:105:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <sqlalchemy.dialects.postgresql.psycopg2.PGDialect_psycopg2 object at 0x7f48e37ff550>
cargs = ()
cparams = {'database': 'musicbrainz_db', 'host': 'musicbrainz_db', 'password': 'musicbrainz', 'port': 5432, ...}
def connect(self, *cargs, **cparams):
> return self.dbapi.connect(*cargs, **cparams)
/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py:393:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dsn = 'dbname=musicbrainz_db user=musicbrainz password=musicbrainz host=musicbrainz_db port=5432'
database = 'musicbrainz_db', user = 'musicbrainz', password = 'musicbrainz'
host = 'musicbrainz_db', port = 5432, connection_factory = None
cursor_factory = None, async = False, kwargs = {}
items = [('dbname', 'musicbrainz_db'), ('user', 'musicbrainz'), ('password', 'musicbrainz'), ('host', 'musicbrainz_db'), ('port', 5432)]
def connect(dsn=None,
database=None, user=None, password=None, host=None, port=None,
connection_factory=None, cursor_factory=None, async=False, **kwargs):
"""
Create a new database connection.
The connection parameters can be specified either as a string:
conn = psycopg2.connect("dbname=test user=postgres password=secret")
or using a set of keyword arguments:
conn = psycopg2.connect(database="test", user="postgres", password="secret")
The basic connection parameters are:
- *dbname*: the database name (only in dsn string)
- *database*: the database name (only as keyword argument)
- *user*: user name used to authenticate
- *password*: password used to authenticate
- *host*: database host address (defaults to UNIX socket if not provided)
- *port*: connection port number (defaults to 5432 if not provided)
Using the *connection_factory* parameter a different class or connections
factory can be specified. It should be a callable object taking a dsn
argument.
Using the *cursor_factory* parameter, a new default cursor factory will be
used by cursor().
Using *async*=True an asynchronous connection will be created.
Any other keyword parameter will be passed to the underlying client
library: the list of supported parameters depends on the library version.
"""
items = []
if database is not None:
items.append(('dbname', database))
if user is not None:
items.append(('user', user))
if password is not None:
items.append(('password', password))
if host is not None:
items.append(('host', host))
if port is not None:
items.append(('port', port))
items.extend([(k, v) for (k, v) in kwargs.items() if v is not None])
if dsn is not None and items:
raise TypeError(
"'%s' is an invalid keyword argument when the dsn is specified"
% items[0][0])
if dsn is None:
if not items:
raise TypeError('missing dsn and no parameters')
else:
dsn = " ".join(["%s=%s" % (k, _param_escape(str(v)))
for (k, v) in items])
> conn = _connect(dsn, connection_factory=connection_factory, async=async)
E psycopg2.OperationalError: could not translate host name "musicbrainz_db" to address: Name or service not known
/usr/local/lib/python3.6/site-packages/psycopg2/__init__.py:164: OperationalError
The above exception was the direct cause of the following exception:
self = <critiquebrainz.frontend.views.test.test_release_group.ReleaseGroupViewsTestCase testMethod=test_release_group_page>
def test_release_group_page(self):
# Basic release group page should be available.
> response = self.client.get("/release-group/c2e0ff67-fb31-4443-ae0e-22ecf010463b")
critiquebrainz/frontend/views/test/test_release_group.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.6/site-packages/werkzeug/test.py:791: in get
return self.open(*args, **kw)
/usr/local/lib/python3.6/site-packages/flask/testing.py:127: in open
follow_redirects=follow_redirects)
/usr/local/lib/python3.6/site-packages/werkzeug/test.py:764: in open
response = self.run_wsgi_app(environ, buffered=buffered)
/usr/local/lib/python3.6/site-packages/werkzeug/test.py:677: in run_wsgi_app
rv = run_wsgi_app(self.application, environ, buffered=buffered)
/usr/local/lib/python3.6/site-packages/werkzeug/test.py:884: in run_wsgi_app
app_rv = app(environ, start_response)
/usr/local/lib/python3.6/site-packages/flask/app.py:1997: in __call__
return self.wsgi_app(environ, start_response)
/usr/local/lib/python3.6/site-packages/flask/app.py:1985: in wsgi_app
response = self.handle_exception(e)
/usr/local/lib/python3.6/site-packages/flask/app.py:1540: in handle_exception
reraise(exc_type, exc_value, tb)
/usr/local/lib/python3.6/site-packages/flask/_compat.py:33: in reraise
raise value
/usr/local/lib/python3.6/site-packages/flask/app.py:1982: in wsgi_app
response = self.full_dispatch_request()
/usr/local/lib/python3.6/site-packages/flask/app.py:1614: in full_dispatch_request
rv = self.handle_user_exception(e)
/usr/local/lib/python3.6/site-packages/flask/app.py:1517: in handle_user_exception
reraise(exc_type, exc_value, tb)
/usr/local/lib/python3.6/site-packages/flask/_compat.py:33: in reraise
raise value
/usr/local/lib/python3.6/site-packages/flask/app.py:1612: in full_dispatch_request
rv = self.dispatch_request()
/usr/local/lib/python3.6/site-packages/flask/app.py:1598: in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
critiquebrainz/frontend/views/release_group.py:18: in entity
release_group = mb_release_group.get_release_group_by_id(id)
critiquebrainz/frontend/external/musicbrainz_db/release_group.py:22: in get_release_group_by_id
includes=['artists', 'releases', 'release-group-rels', 'url-rels', 'work-rels', 'tags']
critiquebrainz/frontend/external/musicbrainz_db/release_group.py:35: in fetch_multiple_release_groups
release_group = get_something_by_gid(query, models.ReleaseGroupGIDRedirect, mbid)
/usr/local/lib/python3.6/site-packages/mbdata/utils/__init__.py:55: in get_something_by_gid
artist = query.filter_by(gid=gid).first()
/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/query.py:2755: in first
ret = list(self[0:1])
/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/query.py:2547: in __getitem__
return list(res)
/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/query.py:2855: in __iter__
return self._execute_and_instances(context)
/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/query.py:2876: in _execute_and_instances
close_with_result=True)
/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/query.py:2885: in _get_bind_args
**kw
/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/query.py:2867: in _connection_from_session
conn = self.session.connection(**kw)
/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py:998: in connection
execution_options=execution_options)
/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py:1003: in _connection_for_bind
engine, execution_options)
/usr/local/lib/python3.6/site-packages/sqlalchemy/orm/session.py:403: in _connection_for_bind
conn = bind.contextual_connect()
/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py:2112: in contextual_connect
self._wrap_pool_connect(self.pool.connect, None),
/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py:2151: in _wrap_pool_connect
e, dialect, self)
/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py:1465: in _handle_dbapi_exception_noconnection
exc_info
/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py:203: in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py:186: in reraise
raise value.with_traceback(tb)
/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py:2147: in _wrap_pool_connect
return fn()
/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py:387: in connect
return _ConnectionFairy._checkout(self)
/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py:766: in _checkout
fairy = _ConnectionRecord.checkout(pool)
/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py:516: in checkout
rec = pool._do_get()
/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py:1229: in _do_get
return self._create_connection()
/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py:333: in _create_connection
return _ConnectionRecord(self)
/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py:461: in __init__
self.__connect(first_connect_check=True)
/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py:651: in __connect
connection = pool._invoke_creator(self)
/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py:105: in connect
return dialect.connect(*cargs, **cparams)
/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py:393: in connect
return self.dbapi.connect(*cargs, **cparams)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
dsn = 'dbname=musicbrainz_db user=musicbrainz password=musicbrainz host=musicbrainz_db port=5432'
database = 'musicbrainz_db', user = 'musicbrainz', password = 'musicbrainz'
host = 'musicbrainz_db', port = 5432, connection_factory = None
cursor_factory = None, async = False, kwargs = {}
items = [('dbname', 'musicbrainz_db'), ('user', 'musicbrainz'), ('password', 'musicbrainz'), ('host', 'musicbrainz_db'), ('port', 5432)]
def connect(dsn=None,
database=None, user=None, password=None, host=None, port=None,
connection_factory=None, cursor_factory=None, async=False, **kwargs):
"""
Create a new database connection.
The connection parameters can be specified either as a string:
conn = psycopg2.connect("dbname=test user=postgres password=secret")
or using a set of keyword arguments:
conn = psycopg2.connect(database="test", user="postgres", password="secret")
The basic connection parameters are:
- *dbname*: the database name (only in dsn string)
- *database*: the database name (only as keyword argument)
- *user*: user name used to authenticate
- *password*: password used to authenticate
- *host*: database host address (defaults to UNIX socket if not provided)
- *port*: connection port number (defaults to 5432 if not provided)
Using the *connection_factory* parameter a different class or connections
factory can be specified. It should be a callable object taking a dsn
argument.
Using the *cursor_factory* parameter, a new default cursor factory will be
used by cursor().
Using *async*=True an asynchronous connection will be created.
Any other keyword parameter will be passed to the underlying client
library: the list of supported parameters depends on the library version.
"""
items = []
if database is not None:
items.append(('dbname', database))
if user is not None:
items.append(('user', user))
if password is not None:
items.append(('password', password))
if host is not None:
items.append(('host', host))
if port is not None:
items.append(('port', port))
items.extend([(k, v) for (k, v) in kwargs.items() if v is not None])
if dsn is not None and items:
raise TypeError(
"'%s' is an invalid keyword argument when the dsn is specified"
% items[0][0])
if dsn is None:
if not items:
raise TypeError('missing dsn and no parameters')
else:
dsn = " ".join(["%s=%s" % (k, _param_escape(str(v)))
for (k, v) in items])
> conn = _connect(dsn, connection_factory=connection_factory, async=async)
E sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not translate host name "musicbrainz_db" to address: Name or service not known
/usr/local/lib/python3.6/site-packages/psycopg2/__init__.py:164: OperationalError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment