Esempio n. 1
0
def getCursorAlch(db, sql_string, funcion=None, **kwargs):
    if db is None:
        return None
    if sql_string is None or sql_string.strip() == '':
        return None

    sqlString = text(sql_string + setLimitString(sql_string, db, **kwargs))

    cursor = []
    try:
        resultCursor = db.execute(sqlString)
    except Exception as e:
        print('!!!!! ERROR !!!!')
        print(e)
        showQueryError(repr(e), queryFormat(sql_string))
        return []

    for row in resultCursor:
        trow = list(row)  #viene en tupla y no me conviene
        if callable(funcion):
            funcion(trow, **kwargs)
        if trow != []:
            cursor.append(trow)
        #if lim:
        #if cont < lim:
        #cont += 1
        #else:
        #break
    return cursor
Esempio n. 2
0
 def __init__(self,conn,**kwparms): #holder=None,script=None,parent=None):
     super(QueryTab,self).__init__(kwparms.get('parent',None))
     self.limit = 1000
     self.conn = conn
     self.connClose = kwparms.get('connClose',False)
     self.holder = kwparms.get('holder',None)
     self.script = kwparms.get('script',None)
     self.fileName = None
     self.browser = QTableView()
     self.baseModel = None
     self.sqlEdit = QTextEdit()
     self.msgLine = QTextEdit()
     self.msgLine.setReadOnly(True)
     self.msgLine.setText("Bienvenido al query masta")
     
     split = QSplitter(Qt.Vertical)
     split.addWidget(self.sqlEdit)
     split.addWidget(self.browser)
     split.addWidget(self.msgLine)
     split.setSizes([50,250,25])
     #split.setRubberBand(1)
     if self.script:
         self.sqlEdit.setText(queryFormat(self.script))
         self.sqlEdit.hide()
     meatLayout = QVBoxLayout()
     meatLayout.addWidget(split)
     self.setLayout(meatLayout)
Esempio n. 3
0
 def execAction(self, context, action):
     TableTreeItem.execAction(self, context, action)
     if action == 'properties':
         #engine = self.getConnection().data().engine
         #inspector = inspect(engine)
         inspector = self.getConnection().inspector
         table_name = self.text()
         schema = self.getSchema().text()
         cadena = queryFormat(
             inspector.get_view_definition(table_name, schema))
         QMessageBox.information(context, "Información de la vista", cadena)
Esempio n. 4
0
 def executeNewScript(self,script):
     self.sqlEdit.setText(queryFormat(script))
     self.execute()
Esempio n. 5
0
 def reformat(self):
     sqlString = self.sqlEdit.document().toPlainText()
     self.sqlEdit.setText(queryFormat(sqlString))