NameError("name 'engine' is not defined",) while 运行 在雪花连接器中使用 pd_writer 方法
NameError("name 'engine' is not defined",) while running using pd_writer method in snowflake-connector
"""Module for acquiring Raw blast Data"""
from simple_salesforce import Salesforce
import sys
import pandas
import pytz
from datetime import datetime,date
import snowflake
from sqlalchemy import create_engine
from snowflake.connector.pandas_tools import pd_writer
import boto3
def sf_To_df(self):
sf_data = self.salesForceAuth.query_all(self.queryColumns)
sf_data=dict(sf_data)
try:
cursor=snowflake.connector.connect(user=snowflake_user_path,password=snowflake_secret_path,account=snowflake_account,warehouse=snowflake_warehouse,database=snowflake_database,schema=snowflake_schema);
for dictKey1, dictValue1 in sf_data.items():
if dictKey1 == "records":
sf_Df = pandas.DataFrame.from_records(dictValue1)
**sf_Df.to_sql(dictKey1, engine, index=False, method=pd_writer)**
except Exception as e:
typ, obj, tb = sys.exc_info()
print("exception while reading the key value: ", e.__repr__(),tb.tb_lineno)
引擎就是你的连接
def sf_To_df(self):
sf_data = self.salesForceAuth.query_all(self.queryColumns)
sf_data=dict(sf_data)
try:
cursor=snowflake.connector.connect(user=snowflake_user_path,password=snowflake_secret_path,account=snowflake_account,warehouse=snowflake_warehouse,database=snowflake_database,schema=snowflake_schema);
for dictKey1, dictValue1 in sf_data.items():
if dictKey1 == "records":
sf_Df = pandas.DataFrame.from_records(dictValue1)
**sf_Df.to_sql(dictKey1, cursor, index=False, method=pd_writer)**
except Exception as e:
typ, obj, tb = sys.exc_info()
print("exception while reading the key value: ", e.__repr__(),tb.tb_lineno)
"""Module for acquiring Raw blast Data"""
from simple_salesforce import Salesforce
import sys
import pandas
import pytz
from datetime import datetime,date
import snowflake
from sqlalchemy import create_engine
from snowflake.connector.pandas_tools import pd_writer
import boto3
def sf_To_df(self):
sf_data = self.salesForceAuth.query_all(self.queryColumns)
sf_data=dict(sf_data)
try:
cursor=snowflake.connector.connect(user=snowflake_user_path,password=snowflake_secret_path,account=snowflake_account,warehouse=snowflake_warehouse,database=snowflake_database,schema=snowflake_schema);
for dictKey1, dictValue1 in sf_data.items():
if dictKey1 == "records":
sf_Df = pandas.DataFrame.from_records(dictValue1)
**sf_Df.to_sql(dictKey1, engine, index=False, method=pd_writer)**
except Exception as e:
typ, obj, tb = sys.exc_info()
print("exception while reading the key value: ", e.__repr__(),tb.tb_lineno)
引擎就是你的连接
def sf_To_df(self):
sf_data = self.salesForceAuth.query_all(self.queryColumns)
sf_data=dict(sf_data)
try:
cursor=snowflake.connector.connect(user=snowflake_user_path,password=snowflake_secret_path,account=snowflake_account,warehouse=snowflake_warehouse,database=snowflake_database,schema=snowflake_schema);
for dictKey1, dictValue1 in sf_data.items():
if dictKey1 == "records":
sf_Df = pandas.DataFrame.from_records(dictValue1)
**sf_Df.to_sql(dictKey1, cursor, index=False, method=pd_writer)**
except Exception as e:
typ, obj, tb = sys.exc_info()
print("exception while reading the key value: ", e.__repr__(),tb.tb_lineno)