熊猫dataframe.to_sql通过名称“ INDEX”创建一个列,而mysql无法处理它的列名称=“ index”

时间:2019-04-04 17:37:42

标签: python mysql pandas

我做了df.to_sql(name ='phishingdataset',con = con,if_exists ='append',index = False)

在我的数据集中没有名称为“ index”的列,就像在mysql中创建表时一样,该名称也创建了一个列。 当我尝试访问此列时,它将引发错误。

我尝试搜索docs和mysql文档,但没有此类参考。

df.to_sql(name='phishingdataset',con=con,if_exists='append',index=False)

在mysql查询中:-

select * from phishingdataset where index=1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'index=1' at line 1

我的模式是:-

+-----------------------------+------------+------+-----+---------+-------+
| Field                       | Type       | Null | Key | Default | Extra |
+-----------------------------+------------+------+-----+---------+-------+
| index                       | bigint(20) | YES  |     | NULL    |       |
| having_IPhaving_IP_Address  | bigint(20) | YES  |     | NULL    |       |
| URLURL_Length               | bigint(20) | YES  |     | NULL    |       |
| Shortining_Service          | bigint(20) | YES  |     | NULL    |       |
| having_At_Symbol            | bigint(20) | YES  |     | NULL    |       |
| double_slash_redirecting    | bigint(20) | YES  |     | NULL    |       |
| Prefix_Suffix               | bigint(20) | YES  |     | NULL    |       |
| having_Sub_Domain           | bigint(20) | YES  |     | NULL    |       |
| SSLfinal_State              | bigint(20) | YES  |     | NULL    |       |
| Domain_registeration_length | bigint(20) | YES  |     | NULL    |       |
| Favicon                     | bigint(20) | YES  |     | NULL    |       |
| port                        | bigint(20) | YES  |     | NULL    |       |
| HTTPS_token                 | bigint(20) | YES  |     | NULL    |       |
| Request_URL                 | bigint(20) | YES  |     | NULL    |       |
| URL_of_Anchor               | bigint(20) | YES  |     | NULL    |       |
| Links_in_tags               | bigint(20) | YES  |     | NULL    |       |
| SFH                         | bigint(20) | YES  |     | NULL    |       |
| Submitting_to_email         | bigint(20) | YES  |     | NULL    |       |
| Abnormal_URL                | bigint(20) | YES  |     | NULL    |       |
| Redirect                    | bigint(20) | YES  |     | NULL    |       |
| on_mouseover                | bigint(20) | YES  |     | NULL    |       |
| RightClick                  | bigint(20) | YES  |     | NULL    |       |
| popUpWidnow                 | bigint(20) | YES  |     | NULL    |       |
| Iframe                      | bigint(20) | YES  |     | NULL    |       |
| age_of_domain               | bigint(20) | YES  |     | NULL    |       |
| DNSRecord                   | bigint(20) | YES  |     | NULL    |       |
| web_traffic                 | bigint(20) | YES  |     | NULL    |       |
| Page_Rank                   | bigint(20) | YES  |     | NULL    |       |
| Google_Index                | bigint(20) | YES  |     | NULL    |       |
| Links_pointing_to_page      | bigint(20) | YES  |     | NULL    |       |
| Statistical_report          | bigint(20) | YES  |     | NULL    |       |
| Result                      | bigint(20) | YES  |     | NULL    |       |
+-----------------------------+------------+------+-----+---------+-------+
32 rows in set (0.00 sec)

0 个答案:

没有答案