这是我的SQL命令行版本。
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 122
Server version: 5.0.95 Source distribution
+---------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| Action | char(1) | NO | | R | |
| EndpointId | int(11) | NO | MUL | NULL | |
| DeviceType | smallint(6) | NO | | NULL | |
| ChannelNumber | smallint(6) | NO | | 0 | |
| ActionDate | date | YES | | NULL | |
| InsertDate | date | YES | | NULL | |
+---------------+-------------+------+-----+---------+-------+
sql_cmd = \
"""insert into cs_remove
(
Action, EndpointId, DeviceType, ChannelNumber, ActionDate, InsertDate
)
VALUES
(
%s, %s, %s, %s, %s, %s
)
"""
print(base_date)
sql_data = ('R', ept_id, ept_type, ept_ch, "NULL", base_date);
该示例最后将0000-00-00放入日期字符串。我想要空值。我可以从mysql命令行执行此操作,但不能从Python执行。任何帮助都将不胜感激。