title: Set SQLAlchemy to use PostgreSQL SERIAL for identity generation
body: <p><strong>Background:</strong></p>
  
  <p>The application I am currently developing is in transition from SQLite3 to PostgreSQL. All the data has been successfully migrated, using the <code>.dump</code> from the current database, changing all the tables of the type</p>
  
  <pre><code>CREATE TABLE foo (
      id INTEGER NOT NULL, 
      bar INTEGER,
      ...
      PRIMARY KEY (id),
      FOREIGN KEY(bar) REFERENCES foobar (id),
      ...
  );
  </code></pre>
  
  <p>to</p>
  
  <pre><code>CREATE TABLE foo (
      id SERIAL NOT NULL, 
      bar INTEGER,
      ...
      PRIMARY KEY (id),
      FOREIGN KEY(bar) REFERENCES foobar (id) DEFERRABLE,
      ...
  );
  </code></pre>
  
  <p>and <code>SET CONSTRAINTS ALL DEFERRED;</code>.</p>
  
  <p>Since I am using SQLAlchemy I was expecting things to work smoothly from then on, after of course changing the <code>engine</code>. But the problem seems to be with the autoincrement of the primary key to a unique value on <code>INSERT</code>.</p>
  
  <p>The table, say <code>foo</code>, I am currently having trouble with has 7500+ rows but the sequence <code>foo_id_seq</code>'s <code>current value</code> is set on <code>5</code>(because I have tried the inserts five times now all of which have failed).</p>
  
  <p><strong>Question:</strong></p>
  
  <p>So now my question is that without explicitly supplying the <code>id</code>, in the <code>INSERT</code> statement, how can I make Postgres automatically assign a unique value to the <code>id</code> field if <code>foo</code>? Or more specifically, have the sequence return a unique value for it?</p>
  
  <p><strong>Sugar:</strong></p>
  
  <p>Achieve all that through the SQLAlchemy interface.</p>
  
  <p><strong>Environment details:</strong></p>
  
  <ul>
  <li>Python 2.6</li>
  <li>SQLAlchemy 8.2</li>
  <li>PostgreSQL 9.2</li>
  <li>psycopg2 - 2.5.1 (dt dec pq3 ext)</li>
  </ul>
  
  <p><em>PS: If anybody finds a more appropriate title for this question please edit it.</em></p>