from xmlrpc.client import Boolean
from sqlalchemy import TIMESTAMP, Column, Integer, String
from sqlalchemy.sql.expression import text
from .database import Base
class Post(Base):
__tablename__ = 'posts'
id = Column(Integer, primary_key=True, nullable=False)
title = Column(String, unique=True, nullable=False)
content = Column(String, nullable=False)
published = Column(Boolean, server_default='True', nullable=False)
created_at= Column(TIMESTAMP(timezone=True), nullable= False, server_default=text)
エラーが見つかりませんでした。それを使用してテーブルを作成しようとするとmodels.Base.metadata.create_all(bind=engine)
、次のエラーが表示されます。
Traceback (most recent call last):
File "C:\Users\MINTU\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlalchemy\sql\schema.py", line 125, in _init_items
spwd = item._set_parent_with_dispatch
AttributeError: type object 'bool' has no attribute '_set_parent_with_dispatch'
The above exception was the direct cause of the following exception:
File "C:\Users\MINTU\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlalchemy\util\compat.py", line 207, in raise_
raise exception
sqlalchemy.exc.ArgumentError: 'SchemaItem' object, such as a 'Column' or a 'Constraint' expected, got <class 'bool'>