LogGUItest.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:Assignment1_Python 作者: zhenmin1993 项目源码 文件源码
def write_entry_db():
    print 'Connecting to MySQL server'
    Message = 'Connecting to MySQL server'
    status = Label(topframe, text = 'Connecting to MySQL server', bd = 1, relief = SUNKEN, anchor =W)
    status.grid(row = 8, sticky=N+E+S+W, columnspan = 2)
    host =  var_host.get()
    user = var_user.get()
    passwd =  var_passwd.get()
    db =  var_dbName.get()
    port =  var_port.get()
    port = int(port)



    try:
        global conn
        global cur
        conn=MySQLdb.connect(host,user,passwd,db,port)
        cur = conn.cursor()
        Message = 'Connected to MySQL server'
        print 'Connected to MySQL server\n'
        status = Label(topframe, text = Message, bd = 1,fg = '#228B22', relief = SUNKEN, anchor =W)
        status.grid(row = 8, sticky=N+E+S+W, columnspan = 2)

        status = Label(topframe, text = 'Waiting For Table Creating...', bd = 1, relief = SUNKEN, anchor =W)
        status.grid(row = 9, sticky=N+E+S+W, columnspan = 2)

        answer = tkMessageBox.askquestion('Computer Application', 'Server Connected, creating new tables?')

        if answer == 'yes': 
            execfile("Creating_Table.py")
            status = Label(topframe, text = 'Tables Created', fg = '#228B22', bd = 1, relief = SUNKEN, \
                anchor =W)
            status.grid(row = 9, sticky=N+E+S+W, columnspan = 2)

        else: 
            execfile("Existing_Table.py")
            status = Label(topframe, text = "Tables checking, if not exist, creat new table", bd = 1, \
                 relief = SUNKEN, anchor =W)
            status.grid(row = 9, sticky=N+E+S+W, columnspan = 2)

        status = Label(topframe, text = 'Table checking passed, please input the following file names', \
            bd = 1,fg = '#228B22', relief = SUNKEN, anchor =W)
        status.grid(row = 9, sticky=N+E+S+W, columnspan = 2)


    except:
        Message = 'Connection Failed! Please Check!'
        print 'Connection Failed! Please Check!'
        status = Label(topframe, text = Message, bd = 1 , fg = 'red',relief = SUNKEN, anchor =W)
        status.grid(row = 8, sticky=N+E+S+W, columnspan = 2)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号