Ejemplo n.º 1
0
def main():
    # test for db.py
    db1 = db.Mysql()
    db1.connect()
    db1.query()
    db1.disconnect()

    # test for sql.py
    sql1 = sql.Mysql()
    res = sql1.query(sql.Testtb1, 'id', 1)
    print(res)

    names = ("apple", "banana", "orange")
    name = random.choice(names)
    print("the random choice is %s" % name)
    res.name = name
    sql1.session.commit()
    res = sql1.query(sql.Testtb1, 'id', 1)
    print(res)

    items = sql1.queryall(sql.Testtb1)
    for res in items:
        print(res)
    sql1.queryall()
Ejemplo n.º 2
0
        self.btn.move(0, 60)
        self.btn1.move(0, 120)
        self.setGeometry(300, 300, 300, 200)
        self.setWindowTitle('Tooltips')
        self.btn.setToolTip("插入操作")
        self.btn1.setToolTip("删除操作")
        self.btn3.setToolTip("查询操作")
        self.btn.clicked.connect(insert.handle_click)
        self.btn1.clicked.connect(delete.handle_click)
        self.btn3.clicked.connect(ask.handle_click)
        self.btn2.clicked.connect(self.sql.commit)
        self.btn4.clicked.connect(self.sql.rollback)


if __name__ == '__main__':
    mysql = sql.Mysql()
    for i in range(8):
        sql_string = "drop view db" + str(i) + ";"
        mysql.create_view(sql_string)
    for i in range(8):
        sql_string = "create view " + "db" + str(i) + " as " + query_sql[i]
        mysql.create_view(sql_string)
    app = QApplication(sys.argv)
    table = MyTable()
    ask = ASK(mysql, table)
    insert = INSERT(mysql)
    delete = DELETE(mysql)

    ex = Example(insert, ask, delete, mysql)
    ex.show()
    sys.exit(app.exec_())
Ejemplo n.º 3
0
__author__ = 'Administrator'
import os
import win32api
import win32con
import wmi
import time
import sys
sys.path.append('./')
import sql

mysql = sql.Mysql('127.0.0.1', 'root', '123456', 'kkk')


def getSysInfo(wmiService=None):
    result = {}
    if wmiService == None:
        wmiService = wmi.WMI()
    # cpu
    for cpu in wmiService.Win32_Processor():
        timestamp = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
        result['cpuPercent'] = cpu.loadPercentage
    # memory
    cs = wmiService.Win32_ComputerSystem()
    os = wmiService.Win32_OperatingSystem()
    result['memTotal'] = int(int(cs[0].TotalPhysicalMemory) / 1024 / 1024)
    result['memFree'] = int(int(os[0].FreePhysicalMemory) / 1024)
    #disk
    result['diskTotal'] = 0
    result['diskFree'] = 0
    for disk in wmiService.Win32_LogicalDisk(DriveType=3):
        result['diskTotal'] += int(disk.Size)
Ejemplo n.º 4
0
def mysqls():
    return sql.Mysql('127.0.0.1', 'root', '123456', 'host')
Ejemplo n.º 5
0
__author__ = 'Administrator'
import os
import win32api
import win32con
import wmi
import time
import sys
sys.path.append('./')
import sql

mysql = sql.Mysql('127.0.0.1', 'root', '123456', 'host')


def getSysInfo(wmiService=None):
    result = {}
    if wmiService == None:
        wmiService = wmi.WMI()
    # cpu
    for cpu in wmiService.Win32_Processor():
        timestamp = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
        result['cpuPercent'] = cpu.loadPercentage
    # memory
    cs = wmiService.Win32_ComputerSystem()
    os = wmiService.Win32_OperatingSystem()
    result['memTotal'] = int(int(cs[0].TotalPhysicalMemory) / 1024 / 1024)
    result['memFree'] = int(int(os[0].FreePhysicalMemory) / 1024)
    #disk
    result['diskTotal'] = 0
    result['diskFree'] = 0
    for disk in wmiService.Win32_LogicalDisk(DriveType=3):
        result['diskTotal'] += int(disk.Size)