title: importing data to sql server database from json
body: <p>I am attempting to import data into a SQL Server 2012 database from a large json file using Python 2.7. Everything in the below code executes and returns no error, however when I go into Sql Server Management Studio and query the table, it returns zero rows. Why is this?</p>
  
  <pre><code>import json, pyodbc
  
  #import data
  path = 'phys2211-001_clickstream_export'
  records = [json.loads(line) for line in open(path)]
  
  #connect to database, create db cursor
  cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=localhost;DATABASE=fall_2013_blended;Trusted_Connection=Yes')
  cursor = cnxn.cursor()
  
  #insert data into db
  for record in records:
      cursor.execute("insert into clickstream_json(json_event) values (?)",json.dumps(record))
  </code></pre>