Prisma

Latest version: v0.15.0

Safety actively analyzes 714772 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 40 of 44

0.6.5

Not secure
What's Changed

Raw queries are now typed with LiteralString

> This change is only applied when [generating recursive types](https://prisma-client-py.readthedocs.io/en/stable/reference/config/#recursive) as mypy does not support `LiteralString` yet.

[PEP 675](https://peps.python.org/pep-0675/) introduces a new string type, `LiteralString`, this type is a supertype of literal string types that allows functions to accept any arbitrary literal string type such as `'foo'` or `'bar'` for example.

All raw query methods, namely `execute_raw`, `query_raw` and `query_first` now take the `LiteralString` type as the query argument instead of `str`. This change means that any static type checker thats supports PEP 675 will report an error if you try and pass a string that cannot be defined statically, for example:

py
await User.prisma().query_raw(f'SELECT * FROM User WHERE id = {user_id}')


This change has been made to help prevent [SQL injection attacks](https://en.wikipedia.org/wiki/SQL_injection).

Thank you to leejayhsu for contributing this feature!

Basic support for filtering by `None` values

You can now filter records to remove or include occurrences where a field is `None` or not. For example, the following query will return all User records with an email that is not None:

py
await client.user.find_many(
where={
'NOT': [{'email': None}]
},
)


It should be noted that nested None checks are not supported yet, for example this is not valid:

py
await client.user.find_many(
where={
'NOT': [{'email': {'equals': None}}]
},
)


It should also be noted that this does not change the return type and you will still have to perform not None checks to appease type checkers. e.g.

py
users = await client.user.find_many(
where={
'NOT': [{'email': None}]
},
)
for user in users:
assert user.email is not None
print(user.email.split(''))


New exception classes

There are two new exception classes, `ForeignKeyViolationError` and `FieldNotFoundError`.

The `ForeignKeyViolationError` is raised when a foreign key field has been provided but is not valid, for example, trying to create a post and connecting it to a non existent user:

py
await client.post.create(
data={
'title': 'My first post!',
'published': True,
'author_id': '<unknown user ID>',
}
)


The `FieldNotFoundError` is raised when a field has been provided but is not valid in that context, for example, creating a record and setting a field that does not exist on that record:

py
await client.post.create(
data={
'title': 'foo',
'published': True,
'non_existent_field': 'foo',
}
)


Added scalar relational fields in create input

The type definitions for creating records now contain the scalar relational fields as well as an alternative to the longer form for connecting relational fields, for example:

prisma
model User {
id String id default(cuid())
name String
email String unique
posts Post[]
}

model Post {
id String id default(cuid())
author User? relation(fields: [author_id], references: [id])
author_id String?
}


With the above schema and an already existent `User` record. You can now create a new `Post` record and connect it to the user by directly setting the `author_id` field:

py
await Post.prisma().create(
data={
'author_id': '<existing user ID>',
'title': 'My first post!',
},
)


This is provided as an alternative to this query:

py
await Post.prisma().create(
data={
'title': 'My first post!',
'author': {
'connect': {
'id': '<existing user ID>'
}
}
},
)


Although the above query should be preferred as it also exposes other methods, such as creating the relational record inline or connecting based on other unique fields.

Prisma Upgrade

The internal Prisma binaries that Prisma Python makes use of have been upgraded from v3.11.1 to v3.13.0. For a full changelog see the [v3.12.0 release notes](https://github.com/prisma/prisma/releases/tag/3.12.0) and [v3.13.0 release notes](https://github.com/prisma/prisma/releases/tag/3.13.0).

Minor Changes

- Fixed typos / outdated commands in the documentation
- Fixed long standing style issue with dark mode in the documentation

New Contributors

Many thanks to q0w and leejayhsu for their first contributions!

Sponsors

![sponsors](https://user-images.githubusercontent.com/23125036/166979887-196378b6-044a-4c3c-973e-4b48c5355627.png)

0.6.4

Not secure
What's Changed

Experimental support for the `Decimal` type

Experimental support for the [Decimal](https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#decimal) type has been added. The reason that support for this type is experimental is due to a missing [internal feature](https://github.com/prisma/prisma/issues/10252) in Prisma that means we cannot provide the same guarantees when working with the Decimal API as we can with the API for other types. For example, we cannot:

- Raise an error if you attempt to pass a `Decimal` value with a greater precision than the database supports, leading to implicit truncation which may cause confusing errors
- Set the precision level on the returned `decimal.Decimal` objects to match the database level, potentially leading to even more confusing errors.

If you need to use Decimal and are happy to work around these potential footguns then you must explicitly specify that you are aware of the limitations by setting a flag in the Prisma Schema:

prisma
generator py {
provider = "prisma-client-py"
enable_experimental_decimal = true
}

model User {
id String id default(cuid())
balance Decimal
}


The `Decimal` type maps to the standard library's [Decimal](https://docs.python.org/3/library/decimal.html) class. All available query operations can be found below:

py
from decimal import Decimal
from prisma import Prisma

prisma = Prisma()
user = await prisma.user.find_first(
where={
'balance': Decimal(1),
or
'balance': {
'equals': Decimal('1.23823923283'),
'in': [Decimal('1.3'), Decimal('5.6')],
'not_in': [Decimal(10), Decimal(20)],
'gte': Decimal(5),
'gt': Decimal(11),
'lt': Decimal(4),
'lte': Decimal(3),
'not': Decimal('123456.28'),
},
},
)


Updates on the status of support for `Decimal` will be posted in 106.

Add triple-slash comments to generated models

You can now add comments to your Prisma Schema and have them appear in the docstring for models and fields! For example:

prisma
/// The User model
model User {
/// The user's email address
email String
}


Will generate a model that looks like this:

py
class User(BaseModel):
"""The User model"""

email: str
"""The user's email address"""


Improved import error message if the client has not been generated

If you try to import `Prisma` or `Client` before you've run `prisma generate` then instead of getting an opaque error message:


>>> from prisma import Prisma
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'Prisma' from 'prisma' (/prisma/__init__.py)


you will now get an error like this:


>>> from prisma import Prisma
Traceback (most recent call last):
...
RuntimeError: The Client hasn't been generated yet, you must run `prisma generate` before you can use the client.
See https://prisma-client-py.readthedocs.io/en/stable/reference/troubleshooting/#client-has-not-been-generated-yet


The query batcher is now publicly exposed

You can now import the query batcher directly from the root package, making it much easier to type hint and providing support for an alternative API style:

py
from prisma import Prisma, Batch

prisma = Prisma()
async with Batch(prisma) as batcher:
...

def takes_batcher(batcher: Batch) -> None:
...


Prisma upgrade

The internal Prisma binaries that Prisma Python makes use of have been upgraded from v3.10.0 to v3.11.1. For a full changelog see the [v3.11.0 release notes](https://github.com/prisma/prisma/releases/tag/3.11.0) and [v3.11.1 release notes](https://github.com/prisma/prisma/releases/tag/3.11.1).

Sponsors

This project is now being sponsored by prisma and techied. I am so incredibly grateful to both for supporting Prisma Client Python 💜

0.6.3

Not secure
What's Changed

This release is a patch release to fix incompatibilities between the documented [MongoDB Prisma Schema](https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#auto) and our version. In `v3.10.0` Prisma made some breaking changes to MongoDB schemas, for example:

- Replacing `default(dbgenerated())` with `default(auto())`
- Replacing `db.Array(ObjectId)` with `db.ObjectId`

This caused some confusion as following an official Prisma guide in their documentation resulted in an error (326).

Bug Fixes

- Disable raw queries for MongoDB as they are not officially supported yet (324)

0.6.2

Not secure
Bug Fixes

In `v0.6.0` we renamed `Prisma` to `Client`, in doing so we accidentally removed the export for the previous `Client` name which was kept for backwards compatibility. This release re-exports it so the following code will no longer raise an error:

py
from prisma import Client


What's Changed

Support for filtering by `in` and `not_in` for `Bytes` fields

For example the following query will find the first record where `binary_data` is either `my binary data` or `my other binary data`.

py
from prisma import Base64
from prisma.models import Data

await Data.prisma().find_first(
where={
'binary_data': {
'in': [
Base64.encode(b'my binary data'),
Base64.encode(b'my other binary data'),
],
},
},
)


And if you want to find a record that doesn't match *any* of the arguments you can use `not_in`

py
from prisma import Base64
from prisma.models import Data

await Data.prisma().find_first(
where={
'binary_data': {
'not_in': [
Base64.encode(b'my binary data'),
Base64.encode(b'my other binary data'),
],
},
},
)


Added `__slots__` definitions

All applicable classes now define the `__slots__` attribute for improved performance and memory usage, for more information on what this means, see the Python [documentation](https://docs.python.org/3/reference/datamodel.html#slots).

New Contributors

Thank you to matyasrichter 💜

0.6.1

Not secure
What's Changed

Support for removing all auto-generated files

Although very rare, it is sometimes possible to get your Prisma Client Python installation into a corrupted state when upgrading to a newer version. In this situation you could try uninstalling and reinstalling Prisma Client Python however doing so will not always fix the client state, in this case you have to remove all of the files that are auto-generated by Prisma Client Python. To achieve this you would either have to manually remove them or download and run a script that we use internally.

With this release you can now automatically remove all auto-generated files by running the following command:


python -m prisma_cleanup


This will find your installed `prisma` package and remove the auto-generated files.

If you're using a custom output location then all you need to do is pass the import path, the same way you do to use the client in your code, for example:


python -m prisma_cleanup app.prisma


Project name change

The name change that occurred in the last release has been reverted, see 300 for reasoning.

0.6.0

Not secure
Apart from lots of bugfixes, this release also introduces transaction return values:

go
firstPost := client.Post.CreateOne(
Post.Title.Set("First Post"),
).Tx()

secondPost := client.Post.CreateOne(
Post.Title.Set("Second Post"),
).Tx()

if err := client.Prisma.Transaction(firstPost, secondPost).Exec(ctx); err != nil {
panic(err)
}

log.Printf("first post result: %+v", firstPost.Result())
log.Printf("second post result: %+v", secondPost.Result())


🌟 **Help us spread the word about Prisma by starring the repo ☝️ or [tweeting](https://twitter.com/intent/tweet?text=Check%20out%20the%20latest%20Prisma%20Go%20Client%20release%20v0.5.1%20%F0%9F%9A%80%0D%0A%0D%0Ahttps://github.com/prisma/prisma-client-go/releases/tag/v0.6.0) about the release.**

Breaking changes

When using transactions, you need to explicitly call .Tx() in each operation.

before:

go
firstPost := client.Post.CreateOne(
Post.Title.Set("First Post"),
)

secondPost := client.Post.CreateOne(
Post.Title.Set("Second Post"),
)

if err := client.Prisma.Transaction(firstPost, secondPost).Exec(ctx); err != nil {
panic(err)
}


after:

go
firstPost := client.Post.CreateOne(
Post.Title.Set("First Post"),
).Tx()

secondPost := client.Post.CreateOne(
Post.Title.Set("Second Post"),
).Tx()

if err := client.Prisma.Transaction(firstPost, secondPost).Exec(ctx); err != nil {
panic(err)
}


Major changes

* feat(transactions): add tx return values (424) steebchen

Changes

* fix(query): use AND queries to allow duplicate fields (429) steebchen
* fix(query): adapt postgres array query type (430) steebchen
* ci(release-drafter): adapt version in tweet link (423) steebchen
* fix(engine): set http timeout to 0 (431) steebchen
* fix(query): fix nil slices for pg array types (432) steebchen
* docs(transaction): adapt transaction syntax (435) steebchen
* fix(transaction): add `Into(interface{})` method for QueryRaw (438) steebchen
* docs(reference): improve transaction examples (436) matthewmueller
* fix(transaction): introduce result method (441) steebchen

Contributors

matthewmueller and steebchen

Extra thanks to robojones for the help with transaction syntax!

Interested in providing feedback for the Go client?

We would like to ask you a few questions and get your feedback about the Go client. We'll send merch along your away as a thank you.
If you're interested, email me at steebprisma.io or join our [public Slack](https://slack.prisma.io) and DM me.

Page 40 of 44

Links

Releases

Has known vulnerabilities

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.