Is there any way to have a Non auto increment integer primary key? I
have this model:

class Component(Base):
    __tablename__ = 'Component'

    appCode = Column(ForeignKey('Application.appCode'),
primary_key=True, nullable=False)
    componentEnumID = Column(ForeignKey('Enumeration.enumID'),
primary_key=True, nullable=False, autoincrement=False)

And when I try and insert into it I get this warning:

Column 'Component.componentEnumID' is marked as a member of the
primary key for table 'Component', but has no Python-side or
server-side default generator indicated, nor does it indicate
'autoincrement=True' or 'nullable=True', and no explicit value is
passed. Primary key columns typically may not store NULL. Note that as
of SQLAlchemy 1.1, 'autoincrement=True' must be indicated explicitly
for composite (e.g. multicolumn) primary keys if
AUTO_INCREMENT/SERIAL/IDENTITY behavior is expected for one of the
columns in the primary key.

And it ignores the values I provide for componentEnumID and generates
SQL without that column, which then fails with:

Cannot insert the value NULL into column 'componentEnumID', table
'DEC_CORE.dbo.Component'; column does not allow nulls. INSERT fails.

How to get around this issue?

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/CACwCsY5rmMQaTmHBeFsuOcum1wT7-mG1UOAm%2BJQhDVaqyqsCwA%40mail.gmail.com.

Reply via email to