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

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

With minimal costs, as much as possible?

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

Python

Hello my friends, how can I create my own AI assistant at absolutely no cost to help me with my daily tasks and university studies

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

Python

On a scale from 1 to 10 where 1 is noob and 10 is senior developer, something like 3.

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

Python

Yaa yaa, i understand now, maybe leave this i am getting in more confusing condition 😅

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

Python

i understand what it say but i not get what i will actually do with this !

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

Python

this part u say, i have one problem, i am making my repo there i will do edit pyproject.toml ?

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

Python

No, you need it for basicly any python project
Library or not

And your question was if you can use [tool] tags in your pyproject.toml
As Clouded said - yes, its intended to be used that way - which is what the docs explain

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

Python

Alembic is general purpose library.
What to do in your case is up to you as a developer 🤷‍♂

If you read those, then you already know all you need to know.
Good luck with implementing Alembic

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

Python

As always
Reading the documentation with care and understanding is important

https://alembic.sqlalchemy.org/en/latest/tutorial.html#using-pyproject-toml-for-configuration

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

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

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

Python

"at absolutely no cost" no such thing, next question

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

Python

WHAT okay so I can maybe do it in 1 month

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

Python

Guys can I build discord bot with only python? And how much experience does it needs

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

Python

Just go back and read you messages before
You asked if [tool] section is ok.

We said it is.

What else do you need to do with it?

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

Python

You already have that file
What is wrong with editing it??

Read the docs again, as you clearly do not understand the purpose of that file

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

Python

Alembic part is described in Alembic docs 🤷‍♂

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

Python

I just finished this docs you send, by this what i understand the pyproject.toml, this docs is for making a library or what??? what it is do against the alembic, alembim part has nothing here.

So actually i found this will need if i will make new library?🥱

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

Python

yaa i read those things already but actually thos3 not explain properly for what case what to do, again i fear to ask you, as u will say 'read source code to understand 😏'
BTW it also say i can remove the alembic.ini file can be removed but will it ok i will remove this, do u prefer to remove the alembic.ini file and only keep the pyprohect.toml and env.py will be sufficient???

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

Python

i understand this, but see the issue there, when i did alembic init pyprojec...
i found the
sqlalchemy.url = driver://user:pass@localhost/dbname thsi line is in my alembic.ini file not in the pyproject.toml file, as this sqlalchemy.url is the config, but in the case of alembic still it not use the pyproject.toml file for config right?
i still need to keep the alembic.ini file and give my database path there, so how this is the good, i think alembic just forcely trying to adopt the pyproject even thsi is not any need to use by any case as the alembic/env.py will have contains the config its fully sluggish ?

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