title: issue while committing data using SQLAlchemy Session object in a Loop
body: <p>I am having a database committing problem with SQLalchemy. Here is my scenario I have a list of records to be added into a table. Once a records is added into a table I need to get the inserted records Id and do another insert into a second table. I am doing these operation under single session. The code structure is given below as I am not allowed to give the code</p>
  
  <p>creates a session object</p>
  
  <p>loop the records list to be inserted:      </p>
  
  <pre><code> do the session.add(obj)
  
   session.commit()
  
   get obj.id
  
   do the session.add(obj2) # with obj2 having the id from the obj
  
   session.commit()
  </code></pre>
  
  <p>here only the last record data is getting committed properly if we have multiple records</p>
  
  <p>Could any one please help me correct this issue.</p>