title: FlushError: Instance <XYZ at 0xc971bac> has a NULL identity key. Not able to insert in sqlalchemy?
body: <p>I have a sqlite db with few tables and I want to insert in one table xyz the table is created with sql alchemy with the following as creat statment.</p>
  
  <pre><code>    CREATE TABLE XYZ (
          some_id FLOAT, 
          creat_date DATETIME, 
          first_name VARCHAR, 
          last_name VARCHAR, 
          xyz_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 
          FOREIGN KEY(some_id) REFERENCES some (some_id),
      )
  </code></pre>
  
  <p>Model for above table I created the tables with metadata.create_all(engine) with use_alter = True to remove cyclic dependency.</p>
  
  <pre><code>    XYZ = Table("XYZ", metadata,
          Column(
          "some_id", Float, ForeignKey('some.some_id'), default=0),
          crt_dt(),
          Column("first_name", String),
          Column("last_name", String),
          Column("xyz_id", Integer, primary_key=True),
          sqlite_autoincrement = True,
          )
  </code></pre>
  
  <p>I checked in sqlite the table is created properly.But when I am inserting data to xyz it says
  FlushError: Instance  has a NULL identity key.  If this is an auto-generated value, check that the database table allows generation of new primary key values, and that the mapped Column object is configured to expect these generated values.  Ensure also that this flush() is not occurring at an inappropriate time, such aswithin a load() event.
  '.'}</p>
  
  <p>I tried inserting with a value for xyz_id = 1 ,surprisingly it accepts the value and populates the data but when I am not giving any value its complaining about Auto Incremented value.
  I will appreciate any help thanks. </p>