def onOkClick(self, event): logger.debug('onOkClick') sqlExecuter = SQLExecuter() sqlTypeObjectList = sqlExecuter.getSqlObjects() if len(sqlTypeObjectList) == 0: sqlExecuter.createOpalTables() sqlExecuter.addNewConnectionRow( self.GetParent().CreateOpenConnectionPanel.filePath, self.GetParent().CreateOpenConnectionPanel.connectionNameText. GetValue()) # data = self.GetTopLevelParent().createImportingCsvPanel.data # tableName = self.GetTopLevelParent().createImportingCsvPanel.tableNameText.GetValue() # fileOperations = FileOperations() # # data = fileOperations.readCsvFile(filePath=filePath, columnNameFirstRow=True, delimiter=",", quotechar='|') # # print(len(data)) # # print(data) # createTableScript = fileOperations.createTableScript(tableName=tableName, columnHeader=data[0]) # print(createTableScript) # sqlList = fileOperations.sqlScript(tableName=tableName, data=data) # print(sqlList) # connectionName = self.GetTopLevelParent().connectionName # importStatus = SQLUtils().importingData(connectionName=connectionName, sqlList=sqlList) # dlg = wx.MessageDialog(self, "Some status", # 'Importing data status', # wx.OK | wx.ICON_INFORMATION # #wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_INFORMATION # ) # dlg.ShowModal() # dlg.Destroy() self.GetTopLevelParent().Destroy()
def createNewDatabase(self, databaseAbsolutePath=None, connectionName=None): try: manageSqliteDatabase = ManageSqliteDatabase( databaseAbsolutePath=databaseAbsolutePath, connectionName=connectionName) manageSqliteDatabase.createTable() sqlExecuter = SQLExecuter() sqlTypeObjectList = sqlExecuter.getSqlObjects() if len(sqlTypeObjectList) == 0: sqlExecuter.createOpalTables() sqlExecuter.addNewConnectionRow(databaseAbsolutePath, connectionName) except OperationalError as err: logger.error(err, exc_info=True)
def OnDropFiles(self, x, y, fileNams): logger.debug("dropFiles {}".format(fileNams)) try: for fileAbsoluteName in fileNams: if os.path.isdir(fileAbsoluteName): continue logger.debug(fileAbsoluteName) if self.isSQLite3(fileAbsoluteName): self.getConnectionName(filePath=fileAbsoluteName) sqlExecuter = SQLExecuter() obj = sqlExecuter.getObject() if len(obj[1]) == 0: sqlExecuter.createOpalTables() sqlExecuter.addNewConnectionRow(fileAbsoluteName, self.getConnectionName(filePath=fileAbsoluteName)) self.dirwin.recreateTree() except Exception as ex: logger.error(ex) return True