我想使用该方法将数据框插入我的Snowflake
数据库to_sql()
。
这就是我试图做到的方式 -
dataframe.to_sql(table_name, engine, index=False, method=pd_writer, if_exists="append")
这就是我的数据框的样子 -
event_id event_timestamp event_type user_name client_ip ... related_event_id instance_id user_id event company_id
0 1298203705 2020-11-05 10:47:43.981000+00:00 LOGIN SHIVKANT 52.149.162.195 ... 0 2 4 1 1
1 1298207325 2020-11-10 10:31:00.263000+00:00 LOGIN SHIVKANT 40.118.225.132 ... 0 2 4 1 1
如果具有所提供名称的表不存在,则该to_sql()
方法的参数会创建一个新表。if_exists
当我运行上述代码时,这就是它在终端上打印的内容-
CREATE TABLE login_history (
event_id BIGINT,
event_timestamp TIMESTAMP,
event_type TEXT,
user_name TEXT,
client_ip TEXT,
reported_client_type TEXT,
reported_client_version TEXT,
first_authentication_factor TEXT,
second_authentication_factor TEXT,
is_success TEXT,
error_code FLOAT,
error_message TEXT,
related_event_id BIGINT,
instance_id BIGINT,
user_id BIGINT,
event BIGINT,
company_id BIGINT
)
- 正在创建的表没有该字段,
primary_key
但我希望它有一个名为.Auto Increment
Primary Key
id
- 上面的代码确实创建了一个表,但是在向表中插入数据时会返回错误。
snowflake.connector.errors.ProgrammingError: 000904 (42000): 0198a74a-0b5e-4dd5-0000-d5e5000a40f6:
SQL compilation error: error line 1 at position 88
invalid identifier '"event_id"'