probablyrobert
probablyrobert on Hacker News
Yeah, sharing the same database between two backends would not be a good idea. That said you do not have to use the TypeScript client at the same time as the Python client, they are independent of each other.
There is actually an escape hatch you can use, although it is a bit clunky:
```py
from typing import TYPE_CHECKING
if TYPE_CHECKING:
Foo = "expression that mypy can understand"
else:
Foo = "dynamic expression"
```
Thank you! I hope so too, it would be incredibly helpful.
Yes it is rather unfortunate, Python's typing system doesn't support dynamically creating types like you can in TypeScript :/
Yes it is similar to SQLModel however as SQLModel is based off of SQLAlchemy, the query API is not typed. That is the difference.
You are correct, we use code generation to define the query API types.
Thanks for the feedback, I will add that.
> Prisma Python
I originally decided to go with Prisma Client Python however I found this to be too verbose and have recently used Prisma Python. I do need to decide on one and stick with that. Thanks for pointing that out
Thanks :)
Yeah that is understandable, it is being successfully used in production but it is safer to use a more stable ORM for mission critical products.
If you don't want to have to duplicate your model definitions you could write a custom Prisma Generator to generate models for a different Python ORM.
https://prisma-client-py.readthedocs.io/en/stable/reference/...
ORM stands for Object Relational Mapper and is essentially a wrapper over raw SQL queries to provide an easier to use interface.
I haven't written benchmarks yet but it is something I am working on. The reason that performance is mentioned in the README is that I haven't spent time on improving it yet.
The biggest blockers in terms of performance are:
- Communication with the internal Rust engine is performed over HTTP instead of FFI.
- You cannot select a subset of fields (every scalar field in a model is selected)
- You cannot skip pydantic validation which while fast is unnecessary in some cases
With that said Prisma Python should be reasonably fast but I would expect it to be on the lower end of the spectrum compared to other Python ORMs. I have ran some load tests locally and creating 500,000 records took about 90 seconds.
Good point, I'll update it, thanks!
Posted by
probablyrobert on Monday February 21, 2022 @09:57AM
from the show-hn dept.
https://github.com/RobertCraigie/prisma-client-py
I created this ORM to fill a gap in the Python ecosystem. Due to the nature of typing in Python there are no other Python ORMs that can provide correct type hints. Prisma Python manages to work around this by auto-generating python types.Aside from static type checking, providing type hints means that you will get autocomplete suggestions for you which for me is the killer feature for this ORM...
Full disclosure, I am the creator of this project.
Happy to answer any questions!
Posted by
probablyrobert on Monday November 15, 2021 @11:29AM
from the github.com dept.
Full disclosure - I am also the creator of this package.
Happy to answer any questions!
Posted by
probablyrobert on Monday October 25, 2021 @08:56AM
from the github.com dept.