|
是的,已建立testdb
並在sublime執行後, 輸入http://127.0.0.1:5000/
接著就出現下面一大串log
/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py:872: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True or False to suppress this warning. warnings.warn(FSADeprecationWarning( * Serving Flask app "models" (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: off * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) [2021-04-19 20:04:34,679] ERROR in app: Exception on / [GET] Traceback (most recent call last): File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2339, in _wrap_pool_connect return fn() File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 364, in connect return _ConnectionFairy._checkout(self) File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 778, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 495, in checkout rec = pool._do_get() File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/pool/impl.py", line 140, in _do_get self._dec_overflow() File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 68, in __exit__ compat.raise_( File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/pool/impl.py", line 137, in _do_get return self._create_connection() File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 309, in _create_connection return _ConnectionRecord(self) File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 440, in __init__ self.__connect(first_connect_check=True) File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 661, in __connect pool.logger.debug("Error on connect(): %s", e) File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 68, in __exit__ compat.raise_( File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 656, in __connect connection = pool._invoke_creator(self) File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect return dialect.connect(*cargs, **cparams) File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 493, in connect return self.dbapi.connect(*cargs, **cparams) File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/psycopg2/__init__.py", line 127, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) psycopg2.OperationalError: FATAL: database "testdb" does not exist
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise raise value File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/Users/hsin-hueichen/Desktop/testdb/models.py", line 24, in index db.create_all() File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 1094, in create_all self._execute_for_all_tables(app, bind, 'create_all') File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 1086, in _execute_for_all_tables op(bind=self.get_engine(app, bind), **extra) File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/sql/schema.py", line 4546, in create_all bind._run_visitor( File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2097, in _run_visitor with self._optional_conn_ctx_manager(connection) as conn: File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/contextlib.py", line 113, in __enter__ return next(self.gen) File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2089, in _optional_conn_ctx_manager with self._contextual_connect() as conn: File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2305, in _contextual_connect self._wrap_pool_connect(self.pool.connect, None), File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2342, in _wrap_pool_connect Connection._handle_dbapi_exception_noconnection( File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1584, in _handle_dbapi_exception_noconnection util.raise_( File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2339, in _wrap_pool_connect return fn() File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 364, in connect return _ConnectionFairy._checkout(self) File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 778, in _checkout fairy = _ConnectionRecord.checkout(pool) File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 495, in checkout rec = pool._do_get() File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/pool/impl.py", line 140, in _do_get self._dec_overflow() File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 68, in __exit__ compat.raise_( File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/pool/impl.py", line 137, in _do_get return self._create_connection() File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 309, in _create_connection return _ConnectionRecord(self) File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 440, in __init__ self.__connect(first_connect_check=True) File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 661, in __connect pool.logger.debug("Error on connect(): %s", e) File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 68, in __exit__ compat.raise_( File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 178, in raise_ raise exception File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 656, in __connect connection = pool._invoke_creator(self) File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect return dialect.connect(*cargs, **cparams) File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 493, in connect return self.dbapi.connect(*cargs, **cparams) File "/Users/hsin-hueichen/opt/anaconda3/lib/python3.8/site-packages/psycopg2/__init__.py", line 127, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) FATAL: database "testdb" does not exist
(Background on this error at: http://sqlalche.me/e/13/e3q8) 127.0.0.1 - - [19/Apr/2021 20:04:34] " [35m [1mGET / HTTP/1.1 [0m" 500 - |