In the documentation of sqlalchemy I read:
class sqlalchemy.types.Boolean(create_constraint=True, name=None)
A bool datatype.
Boolean typically uses BOOLEAN or
SMALLINT on the DDL side, and on the
Python side deals in True or False.Parameters: create_constraint –
defaults to True. If the boolean is
generated as an int/smallint, also
create a CHECK constraint on the table
that ensures 1 or 0 as a value. name –
if a CHECK constraint is generated,
specify the name of the constraint.
I want to use this type in a declarative way, but I want to understand the parameter descripton first. What is meant by create_constraint and name and what do they do? English is not my natural tong and my knowledge about databases is limited, so thanks for any hints.
What I need is something like:
query_status = Column(Boolean, default = False) # Hope the syntax for default value is correct.
What would this mean:
query_status = Column(Boolean, default = False, create_constraint=True, name='some_name')
yep
it deals on the database level (DDL). It creates a
check constraintto make sure the value stays as int/smallint if it ‘s generated as a int/smallint in the databasethe
nameargument is the name for thatcheck constraint.Well, Im just rephrasing the definition. I hope you understand