Answer the question
In order to leave comments, you need to log in
Why does an error occur when declaring a Peewee model field?
I have some model
user = 'test_user'
password = 'qwerty'
db_name = 'diplodog'
from peewee import *
dbhandle = PostgresqlDatabase(
db_name, user=user,
password=password,
host='localhost',
port=5434
)
class Photo (Model):
id = IntegerField()
idpost = IntegerField()
idwall = IntegerField()
# where it is - in a post or comments
where = CharField()
# photo binary
photobytes = BigBitField()
# photobytes = CharField()
# link to which downloaded photo
url = CharField()
# if it is in the comments
idcomment = IntegerField()
class Meta:
database = dbhandle
when I run the code I get a
Traceback error (most recent call last):
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "", line 783, in exec_module
File "", line 219, in _call_with_frames_removed
File "/home/fuckinggirl/PycharmProjects/untitled5/entity/photo.py", line 4, in
class Photo (Model):
File "/home/fuckinggirl/PycharmProjects/untitled5/venv/lib/python3.8/site-packages/peewee.py", line 6044,in __new__
cls._meta.add_field(name, field)
File "/home/fuckinggirl/PycharmProjects/untitled5/venv/lib/python3.8/site-packages/peewee.py", line 5833, in add_field
field.bind(self.model, field_name, set_attribute)
File "/home/ fuckinggirl/PycharmProjects/untitled5/venv/lib/python3.8/site-packages/peewee.py", line 4617, in bind
self._db_hook(model._meta.database)
File "/home/fuckinggirl/PycharmProjects/untitled5/venv /lib/python3.8/site-packages/peewee.py", line 4609, in _db_hook
self._constructor = database.get_binary_type()
File "/home/fuckinggirl/PycharmProjects/untitled5/venv/lib/python3.8/site -packages/peewee.py", line 3773, in get_binary_type
return psycopg2.Binary
AttributeError: 'NoneType' object has no attribute 'Binary'
Process finished with exit code 1
If I change the line
photobytes = BigBitField(),
for example, to
photobytes = CharField(),
then everything works fine. What could be wrong?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question