0

Possible Duplicate:
python csv reader behavior with None and empty string

When reading in a csv file, the reader reads None or NULL as (u''). This is causing me problems when inserting values into a sqlite database and performing queries as all null values are stored as empty strings. Is there a way of using the reader to insert nulls? What I have so far is:

reader = csv.reader(open(filename))
curs.executemany("INSERT INTO mytable VALUES (?,?,?,?)", reader)
Community
  • 1
  • 1
illumi
  • 274
  • 5
  • 17
  • Ah, it's a real shame that the functionality is this limited. – illumi Jan 18 '13 at 14:54
  • I don't think it's limited. I've always thought that `null` in a database instead of the empty string for `VARCHAR`/`TEXT` is annoying. Maybe you should change your schema to use `DEFAULT ''`. – Fredrick Brennan Jan 18 '13 at 14:58

0 Answers0