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
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]
https://wiki.python.org/moin/BeginnersGuide/NonProgrammers
Читать полностью…
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
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 !
Читать полностью…
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.
Читать полностью…
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?
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?
Читать полностью…
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