Python Forum

Full Version: use .sql instead of script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I have one question , is possible to replace one thing on the script . I have the script. It works good, but i would like use text.sql intead of select tab.num from tabulka tab. Is it possible if yes how. I do not find any script, how can i solve this thanks. I use plsql developer
#run script
# Import sqlalchemy's create_engine() function

# Create the database engine
engine = create_engine('oracle+cx_oracle://dw1:dw2@local/DW3')

df = pd.read_sql("""
select
tab.num
from tabulka tab
""",engine)
df.head()

#import data to table

engine = create_engine('oracle+cx_oracle://dw1:dw2@local/DW3')

df.to_sql('tt',con=engine,if_exists='append',index=False)