Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pandas/io/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from pandas.core.datetools import format as date_format
from pandas.core.api import DataFrame, isnull
from pandas import notnull

#------------------------------------------------------------------------------
# Helper execution function
Expand Down Expand Up @@ -244,6 +245,8 @@ def _write_mysql(frame, table, names, cur):
wildcards = ','.join([r'%s'] * len(names))
insert_query = "INSERT INTO %s (%s) VALUES (%s)" % (
table, col_names, wildcards)
# convert NaN to None object
frame = frame.where(notnull(frame), None)
data = [tuple(x) for x in frame.values]
cur.executemany(insert_query, data)

Expand Down