Re: [sqlalchemy] mssql+turbodbc cnnection not working when converted to .exe , however runs fine when it is in .py file
Looks like you need to convince PyInstaller to include the turbodbc library in your executable. This would be a PyInstaller question rather than an SQLAlchemy one. I haven't used PyInstaller, but typically these tools analyse your source code to see which modules you are importing, and include those in the executable. I suspect nothing in your application is explicitly importing turbodbc, so PyInstaller doesn't know that it's necessary to include it. A quick google suggests that maybe you need to write a PyInstaller hook (https://pyinstaller.readthedocs.io/en/stable/hooks.html) that adds the turbodbc package to a list of hidden imports. Hope that helps, Simon On Mon, Oct 14, 2019 at 6:54 AM Pradeep Dhamale wrote: > > Hi Simon, > > thanks for the response , following below is my code and attached is the > snapshot of error for your reference , the code runs fine when it is in py > file , however it fails when i convert it into exe. > > > Code : > > import pandas as pd > from pandas import DataFrame > import numpy as np > import pyodbc > from sqlalchemy import create_engine > import time > import sqlalchemy as db > import pymssql > import pyodbc > from sqlalchemy.sql import text as sa_text > from sqlalchemy.orm import sessionmaker > import os > import turbodbc > > > path1= "Enterpathforexcelfile" > df=pd.read_excel(path1,'Tablename' ,ignore_index=False,index_col=False) > df.fillna('',inplace=True) > > #Performaing panadas dataframe operations > > engine = > create_engine('mssql+turbodbc://:@/?driver=SQL+Server+Native+Client+10.0') > > connection=engine.connect() > query="delete from Tablename;" > engine.execute(query) > > #transfer dataframe to sql server > df.to_sql('Tablename', connection, schema='schemaname',index=False > ,if_exists='append',chunksize=5) > > > > > > On Friday, October 11, 2019 at 2:37:48 AM UTC+5:30, Simon King wrote: >> >> What is the error message when it fails? >> >> On Thu, Oct 10, 2019 at 10:00 AM Pradeep Dhamale >> wrote: >> > >> > i have created a mssql connection using sqlalchemy : mssql+turbodbc >> > engine, >> > the script runs properly when it is a .py file , however whenever i >> > convert the .py file to .exe using pyinstaller --one file , the exe gets >> > generated successfully , but while executing the exe it fails. >> > >> > -- >> > SQLAlchemy - >> > The Python SQL Toolkit and Object Relational Mapper >> > >> > http://www.sqlalchemy.org/ >> > >> > To post example code, please provide an MCVE: Minimal, Complete, and >> > Verifiable Example. See http://stackoverflow.com/help/mcve for a full >> > description. >> > --- >> > You received this message because you are subscribed to the Google Groups >> > "sqlalchemy" group. >> > To unsubscribe from this group and stop receiving emails from it, send an >> > email to sqlal...@googlegroups.com. >> > To view this discussion on the web visit >> > https://groups.google.com/d/msgid/sqlalchemy/54ff39e6-bcff-4545-85cf-a43f9a04f1be%40googlegroups.com. > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sqlalchemy/a2f0dfbd-ef0f-4bba-a93b-98cbf4fcd651%40googlegroups.com. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/CAFHwexe_FGgEx_QxiVoT4Zu70ZvTZ8cNSDK4-kNY9WBPe%2B6z4A%40mail.gmail.com.
Re: [sqlalchemy] mssql+turbodbc cnnection not working when converted to .exe , however runs fine when it is in .py file
Hi Simon, thanks for the response , following below is my code and attached is the snapshot of error for your reference , the code runs fine when it is in py file , however it fails when i convert it into exe. Code : import pandas as pd from pandas import DataFrame import numpy as np import pyodbc from sqlalchemy import create_engine import time import sqlalchemy as db import pymssql import pyodbc from sqlalchemy.sql import text as sa_text from sqlalchemy.orm import sessionmaker import os import turbodbc path1= "Enterpathforexcelfile" df=pd.read_excel(path1,'Tablename' ,ignore_index=False,index_col=False) df.fillna('',inplace=True) #Performaing panadas dataframe operations engine = create_engine('mssql+turbodbc://:@/?driver=SQL+Server+Native+Client+10.0') connection=engine.connect() query="delete from Tablename;" engine.execute(query) #transfer dataframe to sql server df.to_sql('Tablename', connection, schema='schemaname',index=False ,if_exists='append',chunksize=5) On Friday, October 11, 2019 at 2:37:48 AM UTC+5:30, Simon King wrote: > > What is the error message when it fails? > > On Thu, Oct 10, 2019 at 10:00 AM Pradeep Dhamale > > wrote: > > > > i have created a mssql connection using sqlalchemy : mssql+turbodbc > engine, > > the script runs properly when it is a .py file , however whenever i > convert the .py file to .exe using pyinstaller --one file , the exe gets > generated successfully , but while executing the exe it fails. > > > > -- > > SQLAlchemy - > > The Python SQL Toolkit and Object Relational Mapper > > > > http://www.sqlalchemy.org/ > > > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > > --- > > You received this message because you are subscribed to the Google > Groups "sqlalchemy" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to sqlal...@googlegroups.com . > > To view this discussion on the web visit > https://groups.google.com/d/msgid/sqlalchemy/54ff39e6-bcff-4545-85cf-a43f9a04f1be%40googlegroups.com. > > > -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/a2f0dfbd-ef0f-4bba-a93b-98cbf4fcd651%40googlegroups.com.
Re: [sqlalchemy] mssql+turbodbc cnnection not working when converted to .exe , however runs fine when it is in .py file
What is the error message when it fails? On Thu, Oct 10, 2019 at 10:00 AM Pradeep Dhamale wrote: > > i have created a mssql connection using sqlalchemy : mssql+turbodbc engine, > the script runs properly when it is a .py file , however whenever i convert > the .py file to .exe using pyinstaller --one file , the exe gets generated > successfully , but while executing the exe it fails. > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to sqlalchemy+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sqlalchemy/54ff39e6-bcff-4545-85cf-a43f9a04f1be%40googlegroups.com. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/CAFHwexf9p1wUZ_8K4G3a-q0WhXe_qG0nDFZf82uykdRMjhLb2A%40mail.gmail.com.
[sqlalchemy] mssql+turbodbc cnnection not working when converted to .exe , however runs fine when it is in .py file
i have created a mssql connection using sqlalchemy : mssql+*turbodbc* engine, the script runs properly when it is a .py file , however whenever i convert the .py file to .exe using pyinstaller --one file , the exe gets generated successfully , but while executing the exe it fails. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/54ff39e6-bcff-4545-85cf-a43f9a04f1be%40googlegroups.com.