python - Multiple insert statements failing postgresql / psycopg2 -


i'm using scrapy scrape webpage add postgres database. first insert statements works fine, , can select items database. second 1 seems insert data fields blank

           date            | count  ---------------------------+-------  04/2013                   |   03/2013                   |   02/2013                   |  

here code:

#database init     self.conn = psycopg2.connect("dbname='dataproject' user='xxxx' host='localhost' password='xxxxxx'")     self.cursor = self.conn.cursor()          #csv files     self.datavisitemcsv = csv.writer(open('datavistable.csv', 'wb'))     self.datavisitemcsv.writerow(['dates', 'counts'])  def process_item(self, item, spider):     self.datavisitemcsv.writerow([item['dates'], item['counts']])      date_list = item['dates']     count_list = item['counts']      s in date_list:         self.cursor.execute('insert ufo_info(date) values (%s);', [s])      c in count_list:         self.cursor.execute('insert ufo_info(count) values (%s);', [c])      self.conn.commit() 

does have loops? data race?

for s, c in zip(date_list, count_list):     self.cursor.execute(         'insert ufo_info(date, count) values (%s, %s);'         , (s, c)     ) 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -