testdrivenio / testdriven-app

34 stars 18 forks source link

Hello, Was trying to learn from your tutorials and I run into an issue. #26

Closed peacengell closed 6 years ago

peacengell commented 6 years ago

Hello,

Got an issue on this page : https://testdriven.io/part-one-postgres-setup

When running this command: [ docker-compose -f docker-compose-dev.yml run users-service python manage.py recreate_db ]

Can you help me please.

` docker-compose -f docker-compose-dev.yml run users-service python manage.py recreate_db Starting users-db ... done Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2158, in _wrap_pool_connect return fn() File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py", line 403, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py", line 782, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py", line 532, in checkout rec = pool._do_get() File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py", line 1186, in _do_get self._dec_overflow() File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 66, in exit compat.reraise(exc_type, exc_value, exc_tb) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 187, in reraise raise value File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py", line 1183, in _do_get return self._create_connection() File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py", line 350, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py", line 477, in init self.connect(first_connect_check=True) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py", line 667, in connect connection = pool._invoke_creator(self) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 105, in connect return dialect.connect(*cargs, *cparams) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 410, in connect return self.dbapi.connect(cargs, cparams) File "/usr/local/lib/python3.6/site-packages/psycopg2/init.py", line 130, in connect conn = _connect(dsn, connection_factory=connection_factory, kwasync) psycopg2.OperationalError: FATAL: database "users_dev" does not exist

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "manage.py", line 19, in manager.run() File "/usr/local/lib/python3.6/site-packages/flask_script/init.py", line 412, in run result = self.handle(sys.argv[0], sys.argv[1:]) File "/usr/local/lib/python3.6/site-packages/flask_script/init.py", line 383, in handle res = handle(*args, config) File "/usr/local/lib/python3.6/site-packages/flask_script/commands.py", line 216, in call return self.run(args, kwargs) File "manage.py", line 12, in recreate_db db.drop_all() File "/usr/local/lib/python3.6/site-packages/flask_sqlalchemy/init.py", line 971, in drop_all self._execute_for_all_tables(app, bind, 'drop_all') File "/usr/local/lib/python3.6/site-packages/flask_sqlalchemy/init.py", line 955, in _execute_for_all_tables op(bind=self.get_engine(app, bind), extra) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/sql/schema.py", line 4031, in drop_all tables=tables) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1939, in _run_visitor with self._optional_conn_ctx_manager(connection) as conn: File "/usr/local/lib/python3.6/contextlib.py", line 81, in enter return next(self.gen) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1932, in _optional_conn_ctx_manager with self.contextual_connect() as conn: File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2123, in contextual_connect self._wrap_pool_connect(self.pool.connect, None), File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2162, in _wrap_pool_connect e, dialect, self) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1476, in _handle_dbapi_exception_noconnection exc_info File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause reraise(type(exception), exception, tb=exc_tb, cause=cause) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 186, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2158, in _wrap_pool_connect return fn() File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py", line 403, in connect return _ConnectionFairy._checkout(self) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py", line 782, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py", line 532, in checkout rec = pool._do_get() File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py", line 1186, in _do_get self._dec_overflow() File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 66, in exit compat.reraise(exc_type, exc_value, exc_tb) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 187, in reraise raise value File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py", line 1183, in _do_get return self._create_connection() File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py", line 350, in _create_connection return _ConnectionRecord(self) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py", line 477, in init self.connect(first_connect_check=True) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool.py", line 667, in connect connection = pool._invoke_creator(self) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 105, in connect return dialect.connect(cargs, cparams) File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 410, in connect return self.dbapi.connect(*cargs, cparams) File "/usr/local/lib/python3.6/site-packages/psycopg2/init.py", line 130, in connect conn = _connect(dsn, connection_factory=connection_factory, kwasync) sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) FATAL: database "users_dev" does not exist (Background on this error at: http://sqlalche.me/e/e3q8) (testdriven-app) [~/Project/testdriven-app]`

Regards, Manoj

mjhea0 commented 6 years ago

Email me at michael at mherman dot org.

blackeuler commented 4 years ago

I also get this same error when starting the second course about authentication. When I move the directories this error occurs. Ive tried clearing the docker volumes but it does not resolve the issue. I think the issue has to do with the volumes, after running these commands

$ docker-compose stop $ docker-compose rm

I was able to move on with the tutorial. I think this should be added in the tutorial in case peoples volumes don't come down correctly. This was really frustrating...

mjhea0 commented 4 years ago

Apologies. Docker can be really frustrating at times. In the future, if you want to bring down the containers and volumes, run - docker-compose down -v. I run that like 100 times a day. :)

kbhagi commented 4 years ago

My 2 docker containers one for db and the app are up and running. I have followed this tutorial successfully upto this command at the page https://testdriven.io/courses/tdd-flask/flask-blueprints/

When i run this command docker-compose exec users python manage.py recreate_db I am facing this error "users_dev does not exist"

Even after tried all these commands , i get the same error $ docker-compose stop $ docker-compose rm docker-compose down -v