I'm using to_sql to export my dataframe into a SQL Server table however I want to delay the execution of the next line of python code until the insertion has been completed.
I have a OKish understanding of database connections but I'm a bit of a noob when trying to understand how python and sql server communicate.
engine = db.create_engine('mssql+pyodbc://username:password@ServerName/Database?driver=SQL+Server+Native+Client+11.0')
df.to_sql('Table', engine, schema = 'dbo', if_exists='append',index=False)
#Don't execute this until all the records have been added
print("All my records have been added to SQL")
Any help would be greatly appreciated.
Thanks