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

You can, but that's bad practice and domain is about your business logic and that's, I think, strange to validate something here

And you need to map models to your ORM (or whatever you use) models probably, and dataclasses is better here

Pydantic here is like using ladle where you can use spoon

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

Python

so i though pydantic's BaseModel will replace the my core python things what do you say will thsi really bad to use Pydantic's models here for store data and pass to another places

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

Python

Anyone blogging websites expert here

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

Python

Python basic project ideas

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

Python

i think a have already saw type as a keyword... what exactly means?

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

Python

https://docs.python.org/3/library/typing.html

i was reading this docs, and first i encounter this new things, actually i learn little about type hint when using sqlmodel, pydantic like things, but when i read this docs i found in our code we can use like this,

type Vector = list[float]

Vector = list[float]

from typing import TypeAlias
Vector: TypeAlias = list[float]

i found all this will works fully same is this i undersand correctly, so what do you guys prefer for this what would you say to start doing to a fresh who is starting this???

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

Python

https://wiki.python.org/moin/BeginnersGuide/NonProgrammers

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

Python

One thing at the time
Not all of them at once

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

Python

What are you talking about?
What same network??
We are talking about data validation and rules enforcment.

If you mean Docker, this is not the topic here

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

Python

To enforce rules on database layer, go learn SQL
And for that specific DB engine (sqlite, postgres, etc...)

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

Python

Yaa i will try to learn this so however even i do age=Field(lt199) still from external database connection anyone can use the value of 10000 like this and my database will not throw any error, is this a good approach or not? 😅

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

Python

Maybe You means to say when i write gt0,lt199,
this validation will be done by my backend application which take the data via the model, actually database don't know if the value of any range, it support any int value right?

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

Python

gt, lt or any other validation is done by Pydantic, not SQLAlchemy, so its enforced on runtime layer, not database layer

SQLModel is a combination of those two, and Pydantic is the one thats used for serialization and validation

To enforce rules on database layer, you need to use CheckConstraint in sa_column_args on your field

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

Python

Hello Migrations/Alembic Knowing Friends, see my sqlmodel's table class was like this below:

https://hastebin.com/share/ocexinodug.python

Then i did, alembic alembic revision --autogenerate -m "initial migration first time"
As a result i got this below:

https://hastebin.com/share/avanecuqop.scss

What i foudn, this say i need to adjust this upgrade() function as my need always whenever i will do generate a migration script.

But as i am using sqlmodel, i am not fully sure about sqlalchemy's syntax, so what do you guys say how much i will sure this will work, at least what what part i need to learn so that i will sure this autogenerated upgrade() will not cause any issue?

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

Python

I was trying to setup Alembic with my project, i think now i will use postgres later i will fully go to switch to the sqlite, so that my app will work same as before.

With SQLite, the ALTER TABLE command only supports adding or renaming columns. Any other change to columns or constraints is going to be rejected with an error.

This upper i read from a article, so is this means maybe some alembic upgrade, downgrade will work in postgres,mysql but it will fails in sqlite in future?
if this so how i can run the new updated tables and things in the sqlite ?

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

Python

Please ask smart questions.

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

Python

No external dependencies in domain. Dataclass is better here

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

Python

This is not a group to discuss project ideas.

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

Python

See i want to store some data and then retrive those, so what do you say about this,

class OTPPolicy(
BaseModel,
frozen=True,
):
validity_seconds: int = Field(
gt=0,
)

cooldown_seconds: int = Field(
gt=0,
)

max_attempts: int = Field(
gt=0,
)

length: int = Field(
gt=0,
lt=100,
)

Vs Below -> Also i then listen there is:


@dataclass(frozen=True)
class OTPPolicy:
validity_seconds: int
cooldown_seconds: int
max_attempts: int
length: int

what do you say to use what will better, i use BaseModel because it looks fantastic and easy to keep what i need to keep here, and then i listen i should not to use external library in my domain modules, what do you say to use ??? as i think i will use pydantic's BaseModel as normal code which do a lot more easy coding>

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

Python

Use type Vector = list[float] for Python 3.12+ and

Vector: TypeAlias = list[float]

for Python 3.10+ (or 3.9+ ? 🤔). Don't use Vector = list[float] at all.

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

Python

Hello, good morning. I wanted to let you know that the Santander Open Academy is offering a completely free Introduction to Python Programming course. It will be open until December 31, 2026, for anyone who wants to start learning.

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

Python

I need websites to take coaching of python

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

Python

Yes pls sorry forgive me, i will just recreate all my things i got panic to make a proper application with database and external js things all mix, and i think i need to use a lot of things.

Now i am leaving the db topic, as i need to make one database, and only 1 repo should have access this i need to make my app like this right now?

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

Python

yaa yaa you are right, i need to just use same network of my app and my database, so that only my db will be accessible by the app not by any other way, then i am fully ok and not issue ever about my database leak right?

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

Python

What external database??
You dont make database accessible externally, why would you ever do that?

Only your application talks to your database
And your application enforces the rules

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

Python

I meant what i said
I will not explain anymore, you need to know what you are using and how to use that

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

Python

https://pythonbooks.org/free-books/

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

Python

As i checked see, what i researched:
In my existing Class/Table i did add the age field:

age: int | None = Field(
default=None,
gt=0,
lt=199,
)

But when i did alembic autogenerate ->
IT gave me the upgrade function like this below without having the gt, lt values of 0,199,
def upgrade() -> None:
"""Upgrade schema."""
# ### please adjust! -Alembic ###
op.add_column('usermodel',
sa.Column('age',
sa.Integer(),
nullable=True)
)
# ### end Alembic commands ###

so i got confused what i should to do in this case? as when i will run alembic upgrade head, i will found my database will take any value outside 199 range!

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

Python

Arey tell me from which play form I am able to learn coding and python for free

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

Python

this is more an AI question more than a python one, but there are already tons of free AI assistants, look them up online

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