python | Unsorted

Telegram-канал python - Python

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

Subscribe to a channel

Python

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 💚

Читать полностью…

Python

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

Читать полностью…

Python

I need tg Otp received bot Code

Читать полностью…

Python

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


Thanks for your response in this community, i am newly learning python so i havenot proper idea of everything about Sessions here, but by reading the docs in sqlmodel there i found rather than writing my database code in my with session block i need to use
session: Session = Depends(get_session)

but as by reading the Readme of the repo you send, firtsly i found it has not pypi page for now, and not have proper documentation page, so can you help with this how i can use this in my routes.py function to tackle this situations as what i understand the things is.

so how my flask routes fun will loooks like after setup your library and how i can setup this?

Читать полностью…

Python

Thankyou Sir, noted

Can you share me some resource or name of course that will be helpful

Читать полностью…

Python

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/?

Читать полностью…

Python

I need to extract python code from .exe and its on 3.11 I am unable to do it any leads

Читать полностью…

Python

i think most popular one is flask marshmallow

Читать полностью…

Python

Hali Shon, please verify you are human by clicking the button below. You have 90 seconds.

Читать полностью…

Python

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.

Читать полностью…

Python

Can anyone guide me pls

Читать полностью…

Python

Can you help me to learn on topic - python in excel

Читать полностью…

Python

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.

Читать полностью…

Python

Any one having strategy for funded account?

Читать полностью…

Python

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

Читать полностью…

Python

And you can't really use this response_model=whatever in flask.
That's FastAPI concept, not flask's

Читать полностью…

Python

So build it this group is not for request ready made bots

Читать полностью…

Python

from ur github deployment it shows https://pypi.org/project/flask-di/
but it not opens there

Читать полностью…

Python

In actual, I am excercising a Data analyst path

Читать полностью…

Python

Dear Sir, I am a Microsoft Excel user, basically,
Excel has functionally named as "python in excel"

That's what is trying to learn

Читать полностью…

Python

Thank you sweetie 😊

Читать полностью…

Python

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!

Читать полностью…

Python

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 😭

Читать полностью…

Python

🚫 ‎MRXSIM | Unit 7X2 [8444063387] is already banned.

Читать полностью…

Python

What do you want to do exactly? Like readon, editing, writting excel files in python?

Читать полностью…

Python

I m not a programmer but wanna learn to python in excel

Читать полностью…

Python

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

Читать полностью…

Python

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.

Читать полностью…

Python

@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

i was reading sqlmodel docs, i am using Flask+Sqlmodel

As I understand it, the function actually returns 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.

My question is: how can I achieve the same thing in Flask? 🤔

For example, is there an equivalent of FastAPI's 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?
Or, in Flask, is the recommended approach to explicitly convert the object before returning it, something like:
return HeroPublic.model_validate(hero_obj)

Or is there a better/standard approach for production ready code or how you guys real developers tackle this ???

Читать полностью…

Python

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

Читать полностью…
Subscribe to a channel