#!/usr/bin/python3 # coding: utf-8 import xlrd import MySQLdb import unidecode import datetime as dt book = xlrd.open_workbook("excel/bid_excel.xls") sheet = book.sheet_by_index(0) database = MySQLdb.connect (host="localhost", user = "root", passwd = "****", db = "test") cursor = database.cursor() cursor.execute('SET NAMES utf8;') cursor.execute('SET CHARACTER SET utf8;') cursor.execute('SET character_set_connection=utf8;') query = """INSERT INTO `bid_excel`(`one_s`, `createones_date`) VALUES (%s,%s)""" for each in range(1, sheet.nrows): one_s = sheet.row(each)[0].value createones_date = sheet.row(each)[1].value values = (one_s, createones_date) cursor.execute(query, values) cursor.close() database.commit() database.close()
При таком раскладе, в базу заносятся 0000-00-00, т.к по умолчанию NULL