Beispiel #1
0
    def __init__(self, parent=None): 
        QtGui.QWidget.__init__(self, parent) 
        self.ui = Ui_MainWindow() 
        self.ui.setupUi(self) 
 

        
        #QtCore.QObject.connect(self.ui.actionExit, QtCore.SIGNAL("triggered()"), self.close)
		
		
        QtCore.QObject.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.open_file)
Beispiel #2
0
class StartMyMain(QtGui.QMainWindow):
    _name = ""
    def __init__(self, parent=None): 
        QtGui.QWidget.__init__(self, parent) 
        self.ui = Ui_MainWindow() 
        self.ui.setupUi(self) 
 

        
        #QtCore.QObject.connect(self.ui.actionExit, QtCore.SIGNAL("triggered()"), self.close)
		
		
        QtCore.QObject.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.open_file)
		
    def open_file(self):
        name = QtGui.QFileDialog.getOpenFileName(self, "File Open")
        print(name)
        wb = open_workbook(name, encoding_override = "cp1251")

       # ws = wb.sheet_by_name('Лист1')
        ws = wb.sheet_by_index(0)
        if ws.row(0)[1].value == '': i = 2
        else: i = 1

        
        names = []
        for row_index in range(i, ws.nrows):
            names.append((ws.row(row_index)[12].value,))
  
        names = list(set(names))
		#выводим на экран
		#for item in lis:
			#my_list.insert(END, item)
  
		
        con = sqlite3.connect('ebank.db')
	
        with con:
            cursor = con.cursor()
            cursor.execute('pragma foreign_keys=ON')
            cursor.execute('pragma foreign_keys')
            cursor.executemany('INSERT INTO people(name) values(?)', names)

            rows = []
            for row_index in range(i, ws.nrows):
                name = ws.row(row_index)[12].value
                a = list(x.value for x in ws.row(row_index) if x.value != name)
                a[3] = xldate.xldate_as_datetime(a[3], wb.datemode).date()
                a[4] = xldate.xldate_as_datetime(a[4], wb.datemode).date()
                a[8] = xldate.xldate_as_datetime(a[8], wb.datemode).date()
                a[9] = xldate.xldate_as_datetime(a[9], wb.datemode).date()
                a = tuple(a)
                a = (names.index((name,))+1,) + a#сложение кортежей
                rows.append(a)
            cursor.execute('pragma foreign_keys=ON')
            cursor.execute('pragma foreign_keys')
            operation = cursor.executemany('INSERT INTO contract(man_id, summa, numer_dog, days, nachalo, okonchanie, rate, summa_k_uplate, tek_period, tek_nachalo, tek_okonchanie, summa_za_period, vsego_za_period, word_doc) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)', rows)   
			
        con.commit()
        con.close()
        print("База создана")