I am trying to create a python executable using below code.
import pandas as pd
import pyodbc as po
import os
#variables
server = 'DESKTOP-9B94UPJ'
database = 'DB1'
username = 'etluser'
password = 'password'
rawfile_directory='E:\\Projects\\Ebay\\ETLApp\\'
cnxn = po.connect('DRIVER={SQL
Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
df=pd.read_csv(rawfile_directory+"SPSS_Files\\"+filename,usecols=var_filteredCols)
cnxn = po.connect('DRIVER={SQL
Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
sql_stmt = "INSERT INTO "+var_table+" ("+var_DBCols+") values("+var_placeholder+")"
cursor = cnxn.cursor()
cursor.fast_executemany = True
cursor.executemany(sql_stmt, df.values.tolist())
# print(f'{len(df)} rows inserted to the {MY_TABLE} table')
cursor.commit()
cursor.close()
cnxn.close()
I have created an exe using pyinstaller
pyinstaller --onefile etl.py
I want to pass the database credential and the folder path on the runtime to the exe. Can any of experts advise me how to achieve this? Thanks in advance