python program working in .py but not working while making executable file

A simple program containing sql connection with mysql.connector work fine with .py but not working while running executable file (made with pyinstaller), For sql server workbench is used.

following is connection codes

mydb = mysql.connector.connect(host="localhost", user="root", passwd="Abcd11",database="entry",auth_plugin="mysql_native_password")

cursor=mydb.cursor()

sql= "INSERT INTO ledger_list VALUES(%s, %s, %s)"
cursor.execute(sql,(ldgrp, ldname, db_name))
mydb.commit()