Is it possible to use foreign key reference and have oracle partition on same table in sqlalchemy?
Here is how the oracle partition is defined in __table_args__ as a dict
class SQLAlchemyTable(mx.InsertedAtUpdatedAtMixin, Base):
__tablename__ = 'SQLALCHEMY_TABLE'
__table_args__ = {
'info': {
'oracle_partition': """
PARTITION BY RANGE (PARTITION_DATE) INTERVAL (NUMTOYMINTERVAL(1,'MONTH'))
( PARTITION p_init VALUES LESS THAN (TO_DATE('07-12-2018','DD-MM-YYYY')))
"""
},
}
I have found in documentation that ForeignKeyConstraint is defined in __table_args__ but as a tuple not as a dictionary
__table_args__ = (
ForeignKeyConstraint(('LIST', 'STATE'), ['CODES.LIST_ID', 'CODES.ID']),
)
Any help?
You can pass both positional and keyword arguments in __table_args__, as shown in "Table Configuration". Use a tuple holding the positional arguments, and a dictionary of keyword arguments as the last item of the tuple:
class SQLAlchemyTable(mx.InsertedAtUpdatedAtMixin, Base):
...
__table_args__ = (
ForeignKeyConstraint(('LIST', 'STATE'), ['CODES.LIST_ID', 'CODES.ID']),
{
'info': {
'oracle_partition': """
PARTITION BY RANGE (PARTITION_DATE) INTERVAL (NUMTOYMINTERVAL(1,'MONTH'))
( PARTITION p_init VALUES LESS THAN (TO_DATE('07-12-2018','DD-MM-YYYY')))
"""
}
}
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With