title: Saving into SQLite while parsing with Beautiful soup
body: <p>I am scraping real-estate data, which works very well. However, I have some issues/uncertainties with the storing of the data. I do not want to upload all my code here - I hope that's fine. Basically, my approach looks as follows:</p>
  
  <p>In a first step, I create an sql-databse using the package <strong>sqlite3</strong>.</p>
  
  <p>The actual scraping has the following form:</p>
  
  <pre><code>for zip_code in list_zip_codes:
     conn = sqlite3.connect('some_name.db')
     if zip_code_di == zip_code:
        ...
        scraping
        ...
     conn.execute('''INSERT INTO...
     else:
        conn.commit()
        conn.close()
  </code></pre>
  
  <p>For each object I'm pulling, I get a zip-code, which is named zip_code_di here. What I would like to do is to commit the data as soon as the zip-code changes (that's why I use the if-else condition). Does this approach make sense to you? Is there a better/more common way to make sure all the data is stored?</p>