This is showing in my vs-studio terminal:
>>> from app import db #this command is running successful.
>>> db.create_all() # this command not running.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Python\Practice\Flask\env\lib\site-packages\flask_sqlalchemy\__init__.py", line 1039, in create_all
self._execute_for_all_tables(app, bind, 'create_all')
File "D:\Python\Practice\Flask\env\lib\site-packages\flask_sqlalchemy\__init__.py", line 1031, in _execute_for_all_tables
op(bind=self.get_engine(app, bind), **extra)
File "D:\Python\Practice\Flask\env\lib\site-packages\flask_sqlalchemy\__init__.py", line 962, in get_engine
return connector.get_engine()
File "D:\Python\Practice\Flask\env\lib\site-packages\flask_sqlalchemy\__init__.py", line 555, in get_engine
options = self.get_options(sa_url, echo)
File "D:\Python\Practice\Flask\env\lib\site-packages\flask_sqlalchemy\__init__.py", line 570, in get_options
self._sa.apply_driver_hacks(self._app, sa_url, options)
File "D:\Python\Practice\Flask\env\lib\site-packages\flask_sqlalchemy\__init__.py", line 883, in apply_driver_hacks
if sa_url.drivername.startswith('mysql'):
AttributeError: 'bool' object has no attribute 'drivername'
In your code:
app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite://///todo.db" app.config['SQLALCHEMY_DATABASE_URI'] = False app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = Falseremove this line code:
app.config['SQLALCHEMY_DATABASE_URI'] = FalseTry this lines of codes:
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///todo.db' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = FalseAnd for VSCode terminal:
>>> import app>>> from app import db>>> db.create_all()