ProgrammingError: (snowflake.connector.errors.ProgrammingError) 001003 (42000): SQL compilation error:
syntax error line 1 at position 13 unexpected 'sample'. [SQL: '\nCREATE TABLE sample (\n\t"Business Address" TEXT\n)\n\n'] (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)
答案 0 :(得分:2)
SAMPLE
is a reserved keyword在Snowflake(和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")