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)
2
  • Ah, it's a real shame that the functionality is this limited. Commented Jan 18, 2013 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 ''. Commented Jan 18, 2013 at 14:58

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.