Hi, i'm having a troubles detecting auto-increment on reflected tables across different db types.
There is same manually created table in multiple databases of different type: sqlite3 test.db 'create table project (id int primary key not null)' Then reflect it. After reflection, I can check for column attribute autoincrement. But sometimes column.autoincrement is 'auto' instead of true/false. from sqlalchemy import create_engine from sqlalchemy.ext.automap import automap_base engine = create_engine('sqlite:///../test.db') Base = automap_base() Base.prepare(engine, reflect=True) cls = Base.classes['project'] print cls.id.prop.columns[0].autoincrement In my case for db2, oracle, sqlite it is 'auto'. For mysql, mssql, postglesql it is false. As I saw in documentation, this 'auto' is useful when defining tables manually. But what it does on reflected tables?. The default value is the string "auto" which indicates that a single-column > primary key that is of an INTEGER type with no stated client-side or > python-side defaults should receive auto increment semantics automatically; > all other varieties of primary key columns will not. This includes that > DDL <https://docs.sqlalchemy.org/en/13/glossary.html#term-ddl> such as > PostgreSQL SERIAL or MySQL AUTO_INCREMENT will be emitted for this column > during a table create, as well as that the column is assumed to generate > new integer primary key values when an INSERT statement invokes which will > be retrieved by the dialect. > > https://docs.sqlalchemy.org/en/13/core/metadata.html#sqlalchemy.schema.Column.params.autoincrement > So, how to properly check is column auto incremented or not? -- 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/b3dbc610-bf23-415a-b130-31b41b190420%40googlegroups.com.