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
To enforce rules on database layer, go learn SQL
And for that specific DB engine (sqlite, postgres, etc...)
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? 😅
Читать полностью…
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?
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
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?
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.
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
Читать полностью…
On a scale from 1 to 10 where 1 is noob and 10 is senior developer, something like 3.
Читать полностью…
Yaa yaa, i understand now, maybe leave this i am getting in more confusing condition 😅
Читать полностью…
i understand what it say but i not get what i will actually do with this !
Читать полностью…
this part u say, i have one problem, i am making my repo there i will do edit pyproject.toml ?
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
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
As always
Reading the documentation with care and understanding is important
https://alembic.sqlalchemy.org/en/latest/tutorial.html#using-pyproject-toml-for-configuration
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
I meant what i said
I will not explain anymore, you need to know what you are using and how to use that
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,
)
alembic autogenerate ->def upgrade() -> None:
"""Upgrade schema."""
# ### please adjust! -Alembic ###
op.add_column('usermodel',
sa.Column('age',
sa.Integer(),
nullable=True)
)
# ### end Alembic commands ###
Arey tell me from which play form I am able to learn coding and python for free
Читать полностью…
this is more an AI question more than a python one, but there are already tons of free AI assistants, look them up online
Читать полностью…
"at absolutely no cost" no such thing, next question
Читать полностью…
Guys can I build discord bot with only python? And how much experience does it needs
Читать полностью…
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?
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
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?🥱
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???
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 ?