Комментарии:
I cant see the values stored in my db!!!
ОтветитьFor others with runtime context error:
On the python shell I discovered you also need to run
from hello import app
app.app_context().push()
Then you can db.create_all()
make the font more bigger please, now I can see 18 line of code only, I want to see 8 line
ОтветитьI am getting this error raise RuntimeError(unbound_message) from None
RuntimeError: Working outside of application context.
This typically means that you attempted to use functionality that needed
the current application. To solve this, set up an application context
with app.app_context(). See the documentation for more information.
Why? UnboundLocalError: local variable 'our_users' referenced before assignment!!!!
Review and repeat and find no error!
Does everybody that uses flash just dump everything into the same damn file is there not any example anywhere at all where this isn't done cause I can't find it and it's actually quite ridiculous
ОтветитьI NEED SOME SERIOUS HELP. When I entered "from hello import db" I get nothing, no response at all. no errors, but no confirmation as well and when i tried the create_all(), I got a bunch of errors. I can't proceed. I looked it up myself but I can't find anything useful. I even tried to skip using sqlite and head over the mysql one, but the same problem persist. Please help.
ОтветитьUPDATE
I was getting errors when trying to create the database. I put this in my code:
with app.app_context():
db.create_all()
I added this (for a single run) underneath the class that defined the db.Columns().
I also may have ran db.init_app(app) in between that and the class (or at some point in cmd - importing both db and app), I don't remember where or if that helped or not.
Either way, I got it working now (5/5/23)
while running the db.create_all() command i got the "RuntimeError: Working outside of application context". please help me out. I have been following along with the Flask Friday since day 1.
Ответитьplease the winpty python command doesn't work for me !!
ОтветитьHi! This is really great and I am following it for my first flask app project, but I've made my databases + tables in the MySQL workbench and I'm having a lot of trouble connecting the app to my tables (i.e. sending the outputs of my form to the tables initiated in workbench). Would you please add an explanation on how to connect to an existing table (instead of creating one directly in the script)? Thanks a lot!
Ответитьthank you sir. Could you accept my request? Can you say "You are goddam right"?
ОтветитьThe video awesome. however, somehow i am not able to get the table displayed as i add the users and it does not get saved down. The userid is not incremental by 1 as i add user. wonder why? i am using kali-linux and code-oss
ОтветитьHi, I am unable to create db.. using db.create_all().... I am getting following error : " This typically means that you attempted to use functionality that needed
the current application. To solve this, set up an application context with app.app_context()." ... I have tried to use with function
def create_app():
app = Flask(__name__)
with app.app_context():
...,
but it doesnt resolve the error.. can you please help
Thank You!
Please make a Complete Machine Learning Series
Hi, I've tried to add "dateOfBirth = db.Column(db.DateTime)" to the Users(db.Model) class, but it doesn't work. I Googled for two days, but I cannot find a decent answer. When I change the data type to string as in "dateOfBirth = db.Column(db.String(10)" is works just fine. It seems that sqlalchemy doesn't recognise the 'datetime' data type for entering text. When I change it to "dateOfBirth = db.Column(db.DateTime, default=datetime.utcnow)" and remove the birthday text field from the form, it works fine too. I tried very possible format like "YYYY-MM-DD", "YYYY-MM-DD HH:Mi:Sc.xxxxxx" etc. but no change in result. This is the StatementError: "sqlalchemy.exc.StatementError: (builtins.TypeError) SQLite DateTime type only accepts Python datetime and date objects as input. [SQL: INSERT INTO users (created, "firstName", "lastName", "dateOfBirth", email, phone) VALUES (?, ?, ?, ?, ?, ?) [parameters: [{'email': '[email protected]', 'phone': '+112345678', 'dateOfBirth': '2001-01-01', 'lastName': 'Doe', 'firstName': 'John'}]]"
Any tips how to book more success? Thanks a lot!
i keep getting this error
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such column: users.date_added
help plzz