title: Creating engine in SQLAlchemy: could not translate host name to address: Name or service not known
body: <p>I am executing the following <a href="http://github.com/NoahCarnahan/plagcomps" rel="nofollow noreferrer">project</a> in linux mint 17.2.</p>
  
  <p>I installed the necessary modules and created the database server and created an additional file called 'dbconstants.py' with the database details. </p>
  
  <p><img src="https://i.stack.imgur.com/YynZF.png" alt="Database details"></p>
  
  <pre><code>username = 'postgres'
  password = 'postgres'
  dbname = 'mydb'
  </code></pre>
  
  <p>I am trying to execute the project partially as follows:</p>
  
  <p><code>python -m plagcomps.extrinsic.extrinsic_testing</code></p>
  
  <p>However, I am receving the following error</p>
  
  <pre><code>Traceback (most recent call last):
    File "/usr/lib/python2.7/runpy.py", line 151, in _run_module_as_main
      mod_name, loader, code, fname = _get_module_details(mod_name)
    File "/usr/lib/python2.7/runpy.py", line 101, in _get_module_details
      loader = get_loader(mod_name)
    File "/usr/lib/python2.7/pkgutil.py", line 464, in get_loader
      return find_loader(fullname)
    File "/usr/lib/python2.7/pkgutil.py", line 474, in find_loader
      for importer in iter_importers(fullname):
    File "/usr/lib/python2.7/pkgutil.py", line 430, in iter_importers
      __import__(pkg)
    File "plagcomps/__init__.py", line 8, in &lt;module&gt;
      import intrinsic
    File "plagcomps/intrinsic/__init__.py", line 2, in &lt;module&gt;
      from cluster import cluster
    File "plagcomps/intrinsic/cluster.py", line 4, in &lt;module&gt;
      import classify
    File "plagcomps/intrinsic/classify.py", line 173, in &lt;module&gt;
      Base.metadata.create_all(engine)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/schema.py", line 3687, in create_all
      tables=tables)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1855, in _run_visitor
      with self._optional_conn_ctx_manager(connection) as conn:
    File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
      return self.gen.next()
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1848, in _optional_conn_ctx_manager
      with self.contextual_connect() as conn:
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2039, in contextual_connect
      self._wrap_pool_connect(self.pool.connect, None),
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2078, in _wrap_pool_connect
      e, dialect, self)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1405, in _handle_dbapi_exception_noconnection
      exc_info
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/compat.py", line 199, in raise_from_cause
      reraise(type(exception), exception, tb=exc_tb)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2074, in _wrap_pool_connect
      return fn()
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 376, in connect
      return _ConnectionFairy._checkout(self)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 713, in _checkout
      fairy = _ConnectionRecord.checkout(pool)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 480, in checkout
      rec = pool._do_get()
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 1060, in _do_get
      self._dec_overflow()
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__
      compat.reraise(exc_type, exc_value, exc_tb)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 1057, in _do_get
      return self._create_connection()
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 323, in _create_connection
      return _ConnectionRecord(self)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 449, in __init__
      self.connection = self.__connect()
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 607, in __connect
      connection = self.__pool._invoke_creator(self)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/strategies.py", line 97, in connect
      return dialect.connect(*cargs, **cparams)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 385, in connect
      return self.dbapi.connect(*cargs, **cparams)
    File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 179, in connect
      connection_factory=connection_factory, async=async)
  sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not translate host name "mydb" to address: Name or service not known
  </code></pre>
  
  <p>UPDATE: I modified the dbconstants.py as follows:</p>
  
  <pre><code>username = 'postgres'
  password = 'postgres'
  dbname = 'localhost'
  </code></pre>
  
  <p>And then I receive the following error:</p>
  
  <pre><code>/usr/lib/pymodules/python2.7/matplotlib/__init__.py:1173: UserWarning:  This call to matplotlib.use() has no effect
  because the backend has already been chosen;
  matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
  or matplotlib.backends is imported for the first time.
  
    warnings.warn(_use_error_msg)
  Traceback (most recent call last):
    File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
      "__main__", fname, loader, pkg_name)
    File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
      exec code in run_globals
    File "/home/eadaradhiraj/Downloads/plagcomps/extrinsic/extrinsic_testing.py", line 615, in &lt;module&gt;
      save_to_db=False, ignore_high_obfuscation=False, show_false_negpos_info=False, get_best_of=False)
    File "/home/eadaradhiraj/Downloads/plagcomps/extrinsic/extrinsic_testing.py", line 553, in test
      mid = fingerprintstorage.get_mid(method, n, k, atom_type, hash_size)
    File "plagcomps/extrinsic/fingerprintstorage.py", line 313, in get_mid
      with _get_connection(autocommit=True) as conn:
    File "plagcomps/extrinsic/fingerprintstorage.py", line 92, in _get_connection
      conn = psycopg2.connect(user = username, password = password, database = dbname.split("/")[1], host="localhost", port = 5432)
  IndexError: list index out of range
  </code></pre>