The Client hasn't been generated yet
Badetuch opened this issue · comments
Bug description
Running 'prisma generate' or 'prisma db push' works fine but whenever I try to run my code in PyCharm I get the following output:
Traceback (most recent call last): File "D:\Users\badet\Desktop\cloudbot\main.py", line 9, in <module> from prisma import Prisma File "<frozen importlib._bootstrap>", line 1075, in _handle_fromlist File "D:\Users\badet\PycharmProjects\1\venv\lib\site-packages\prisma\__init__.py", line 50, in __getattr__ raise RuntimeError( 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 Process finished with exit code 1
my main.py:
import datetime
import os
from termcolor import colored
import ts3
import mariadb
import sys
import asyncio
from prisma import Prisma
from prisma import Client
# Initialize Prisma client
prisma = Client()
# Authenticate your bot with Prisma
bot_email = "hello@badespeak.net" # Replace with your bot's email address
bot_password = "GnbacoapJQ5MQ43#" # Replace with your bot's password
# Assuming you have a User model in your Prisma schema
authenticated_bot = prisma.user.find_first(where={"email": bot_email, "password": bot_password})
if authenticated_bot:
bot_id = authenticated_bot.id
print(f"Bot authenticated with ID: {bot_id}")
How to reproduce
Steps to reproduce the behavior:
- prisma generate or prisma push db
- run code
Expected behavior
I expected my code to start like usually.
Prisma information
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-py"
recursive_type_depth = 5
interface = "asyncio"
}
model users {
id Int @id @default(autoincrement())
uid String
createdAt DateTime @default(now())
nickname String
trustfactor Int
}
Environment & setup
- OS: Windows 11
- Database: Supabase PostgreSQL
- Python version: 3.10.4
- Prisma version: 5.4.2
For some reason changing the Python interpreter fixed the issue...