I have python script that have different modules like : MYSQLdb
(update.py) Python Script:
import fileinput
import sys
import os
import re
import subprocess
import MySQLdb
#############################################################################
# **DB Functions:::
def fetch_pn (host,username,password,db_name):
# Open database connection
db = MySQLdb.connect(host,username,password,db_name)
# prepare a cursor object using cursor() method
cursor = db.cursor()
# execute SQL query using execute() method.
sql_pickupNum="SELECT * from orderNO"
cursor.execute(sql_pickupNum)
# Fetch a single row using fetchone() method.
data = cursor.fetchone()
#print "pickup number in mainDB : %s " % data
pn_DB=data
return pn_DB
try:
# Commit your changes in the database
db.commit()
except:
# Rollback in case there is any error
db.rollback()
# disconnect from server
db.close()
mainDB_pn=fetch_pn("localhost","username","password","DB1")
secondDB_pn=fetch_pn("localhost","username","password","DB2")
#############################################################################
ask=raw_input("Enter 1 for main DB or 2 for second DB ???")
if int(ask)==2 :
print "the old value now in mainDB_pn :%s"%secondDB_pn
print"Converting to secondDB"
update_pn("localhost","username","password","DB2",mainDB_pn)
print "The new value of secondDB_PN =%s"%mainDB_pn
elif int(ask)==1:
print "the old value now in mainDB_pn :%s"%mainDB_pn
print"Converting to mainDB"
update_pn("localhost","username","password","DB1",secondDB_pn)
print "The new value of mainDB_PN =%s"%secondDB_pn
and i ve created setup.py:
from distutils.core import setup
import py2exe
setup(console=['update.py'])
and here is the python command to convert the script to exe:
python setup.py py2exe
and this command cause to this error :
how to solve this problem?