如何修复Snowflake数据库写入错误:Snowflke.Connector.errors.ProgrammingError)001003(42000) [英] How to fix Snowflake database write error: snowflake.connector.errors.ProgrammingError) 001003 (42000)
本文介绍了如何修复Snowflake数据库写入错误:Snowflke.Connector.errors.ProgrammingError)001003(42000)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ProgrammingError: (snowflake.connector.errors.ProgrammingError) 001003 (42000): SQL compilation error:
syntax error line 1 at position 13 unexpected 'sample'. [SQL: '
CREATE TABLE sample (
"Business Address" TEXT
)
'] (Background on this error at: http://sqlalche.me/e/f405)
已安装必要的程序包:pip install --upgrade snowflake-sqlalchemy
from sqlalchemy import create_engine
engine = create_engine(
'snowflake://{user}:{password}@{account}/SAMPLE_WORK/public?warehouse=****&role=myrole'.format(user='***',password='****',account='*****')
)
df.to_sql('sample', engine, if_exists='replace', index=False)
推荐答案
SAMPLE
is a reserved keyword在雪花(和Sql:2003)中,但snowflake-sqlalchemy
方言似乎没有正确引用。一个捷径是将其注入保留字集合:
# Before creating the engine etc.
from snowflake.sqlalchemy.base import SnowflakeIdentifierPreparer
# The set uses lower case, though the source set upper.
SnowflakeIdentifierPreparer.reserved_words.add("sample")
这篇关于如何修复Snowflake数据库写入错误:Snowflke.Connector.errors.ProgrammingError)001003(42000)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文