135201
You will be muted until you read the rules. Read them! @Rules_for_Python A group about the Python programming language. Offtopic things go here: @pythonofftopic Resources to learn python: @pythonres Group for Hy: @hylang Selenium: @SeleniumPython
previously i didnot found this sorry, as i didnot see this pypi link in ur readme, i thought this is not exists in pypi, now i get this,
https://pypi.org/project/di-flask/
This i found, maybe i need to learn a little more to use ur library.
So ur library will help me to use the session: Session = Depends(get_session)
in my flask routes function so that i dont need to write the with block in all the database related function, am i right?
but can you say how i will use the Depends() <- fastapi, as this comes from fastapi here how i will use this in my flask routes.py, ooo ur library has this one Depends 💚
Flask does not have Depends function, FastAPI does
What do you mean there is no PyPi project for di-flask?
https://pypistats.org/packages/di-flask
Documentation is in README in GitHub repository
https://github.com/razorblade23/di-flask
Its very simply to use and basically gives you that Depends that FastAPI has but for the use in flask
As Per Sqlmodel Docs below is the sample code:
def get_session():
with Session(engine) as session:
yield session
# Code here omitted 👈
@app.post("/heroes/", response_model=HeroPublic)
def create_hero(*, session: Session = Depends(get_session), hero: HeroCreate):
db_hero = Hero.model_validate(hero)
session.add(db_hero)
session.commit()
session.refresh(db_hero)
return db_hero
session: Session = Depends(get_session)
Thankyou Sir, noted
Can you share me some resource or name of course that will be helpful
can you pls elaborate this logic, i am confsued and not know and listen anythign, i want to like this, fastapi's response model, easy way what you say some article or what/?
Читать полностью…
I need to extract python code from .exe and its on 3.11 I am unable to do it any leads
Читать полностью…
Hali Shon, please verify you are human by clicking the button below. You have 90 seconds.
Читать полностью…
Well, you should do a course in python and learn the according libraries to use excel, i've used some.
I wouldn't say it's extremely difficult.
Yaa, by the way thanks for trying to help me, i am actually want to get help from this python community who have already use this thigns.
Читать полностью…
I have made FastAPI style DI for flask if you want to use it: https://github.com/razorblade23/di-flask
Otherwise, you can use g to keep the session "opened" but i would advise against that as session should be closed on every transaction.
Its better to open session on each transaction and close it afterwards, prefferebly using with Session(engine) as session: context manager
And you can't really use this response_model=whatever in flask.
That's FastAPI concept, not flask's
So build it this group is not for request ready made bots
Читать полностью…
from ur github deployment it shows https://pypi.org/project/flask-di/
but it not opens there
Dear Sir, I am a Microsoft Excel user, basically,
Excel has functionally named as "python in excel"
That's what is trying to learn
Omg hey! so like, you're literally doing way too much here tbh. files.upload() already saves the zips to your colab folder automatically! You don't need that whole for loop at the bottom to write the files all over again, that's prob why it's crashing and acting super weird. Just delete everything after the upload() line and you're good to go bestie!
Читать полностью…
from google.colab import files
import os
uploaded = files.upload() # select all 4 zips at once in the picker
for name, data in uploaded.items():
with open(name, 'wb') as f:
f.write(data)
print(f'{name}: {len(data)/1e6:.1f} MB saved')
Am trying to run this but failed..any corrections 😭
What do you want to do exactly? Like readon, editing, writting excel files in python?
Читать полностью…
I m not a programmer but wanna learn to python in excel
Читать полностью…
yaa i like to chat and discusss about python and programming in general i am also learning things alone, so frieds are very welcome and appriciated, i also wish others to message me for talking like this things
Читать полностью…
you pasted the code from the sqlmodel docs ?
here the session is a context manager, as the sqlmodel session, but as later i will use the di-flask library as says in upper message in reality but here session i shows as the docs say to use.
@app.post("/heroes/", response_model=HeroPublic)
def create_hero(hero: HeroCreate):
with Session(engine) as session:
db_hero = Hero.model_validate(hero)
session.add(db_hero)
session.commit()
session.refresh(db_hero)
return db_hero
db_hero, which is a Hero model instance. However, because response_model=HeroPublic is specified in the FastAPI decorator, FastAPI automatically validates/converts the returned object according to the HeroPublic response model.response_model that I can specify in a Flask route decorator, so that my function can simply return a Hero object and Flask automatically serializes/validates it according to a HeroPublic schema?return HeroPublic.model_validate(hero_obj)
I was trying to use SqlModel , Pydantic in a flask web app, the problem i am finding, like my confusion is i found some code examples like they are using flask.g, actually i am confused should i will use this in my real code to generate session for the sqlmodel, as in flask there is not any Depends like fastapi has one,
i am confused how i should start using the session when i will follow the sqlmodel functions for login, register or some others things,
my main problem is shoudl i start using this, i dont know will this ok in real production,
def get_db_session() -> Session:Читать полностью…
if "db_session" not in g:
g.db_session = Session(engine)
return g.db_session