title: Making a column auto-increment when autoincrement doesn't work (Sqlalchemy, PostgreSQL)
body: <p>I made a simple table using sqlalchemy.</p>
  
  <pre><code>from sqlalchemy import create_engine  
  from sqlalchemy.ext.declarative import declarative_base  
  from sqlalchemy.orm import sessionmaker
  from sqlalchemy import Table, Column, ForeignKey, MetaData, Sequence
  from sqlalchemy.orm import relationship
  from sqlalchemy import INTEGER, REAL, VARCHAR, TIMESTAMP, BOOLEAN, Integer
  import psycopg2 as pg
  import psycopg2.extras
  
  db_string = "postgresql://someDBInfoString"
  db = create_engine(db_string)
  base = declarative_base()
  
  Session = sessionmaker(db)    
  session = Session()           
  
  class Women(base):
      __tablename__ = "WOMEN"
      id = Column(Integer, primary_key=True)
      name = Column(VARCHAR)
      man = relationship("Men", uselist=False, back_populates="woman") 
  </code></pre>
  
  <p>I tried several ways as below to make the <code>id</code> column have <code>Serial</code> type or an equivalent of it that can autoincrement. </p>
  
  <p>1) Setting it as PK </p>
  
  <p>2) Adding <code>autoincrement=True</code> keyword arg</p>
  
  <pre><code>id = Column(Integer, autoincrement=True, primary_key=True)
  </code></pre>
  
  <p>3) Passing <code>Sequence</code></p>
  
  <pre><code>id = Column(Integer, Sequence('seq_tramos_id', start=1, increment=1), primary_key=True)
  </code></pre>
  
  <p>But in every method, <code>id</code> column is set as a plain Integer type on DBMS and inserting a data through DBMS (Postgresql) requires manually including <code>id</code> along with the other value. Inserting a data with ORM using session as in <code>session.add(somestring)</code> is no problem as <code>id</code> is automatically set just as I intended. So this is a problem of how ORM-created table works on DBMS.</p>
  
  <p>What else can I try?</p>
  
  <p>edit : added import and detailed description</p>