Exemplo n.º 1
0
    def insertSomeData(self, tableName, field1, field2, word1, word2):
        tables = self.showTables()

        if (tables is None):
            self.createOneColTable(tableName)
        else:
            if (ms.inEqual(tableName, tables)):
                pass
            else:
                self.createOneColTable(tableName)

        col = self.getColName(tableName)

        if (ms.inEqual(field1, col)):
            pass
        else:
            self.addColTable(tableName, field1, 34)

        col = self.getColName(tableName)

        data = self.selectFieldData(tableName, 'word')

        if (data is None or (not ms.inEqual(word1, data))):
            self.insertTwoDataOnly(tableName, field2, word1, word2)
        else:
            self.updateParticularDataByAdding(tableName, field1, field2, word1,
                                              word2)
Exemplo n.º 2
0
    def insertInIdentity(self, word, identity):
        tables = self.showTables()

        oddTables = ms.oddOut(tables, identity)
        #Table creation if not present
        if (len(oddTables) == 0):
            pass
        else:
            for i in oddTables:
                field = ['word']
                size = [100]
                self.createTable(i, field, size)

        for i in identity:
            data = self.selectAllData(i)

            if (data == None):
                sqlFormula = 'insert into ' + i + ' values("' + word + '")'

                self.mycursor.execute(sqlFormula)
            else:
                if (ms.inEqual(word, data)):
                    pass
                else:
                    sqlFormula = 'insert into ' + i + ' values("' + word + '")'
                    self.mycursor.execute(sqlFormula)
Exemplo n.º 3
0
    def insertInAlfa(self, word, identity):
        tableName = word[0]
        cols = self.getColName(tableName)
        data = self.selectAllData(tableName)
        dic = {}

        if data == None:

            newIdentity = ms.mergeString(identity, '/')
            sqlFormula = 'insert into ' + tableName + ' values("' + word + '","' + newIdentity + '")'

            self.mycursor.execute(sqlFormula)
        else:
            d1 = []
            for i in data:
                dic.__setitem__(i[0].lower(), i[1].lower())
                d1.append(i[0].lower())

            if (ms.inEqual(word, d1)):

                ident = dic[word]

                dis = ms.distributeString(ident, '/')

                nident = ms.sortOut(dis, identity)
                newmid = ms.mergeString(nident, '/')
                self.updateParticularData(tableName, cols[0], cols[1], word,
                                          newmid)

            else:
                newIdentity = ms.mergeString(identity, '/')
                sqlFormula = 'insert into ' + tableName + ' values("' + word + '","' + newIdentity + '")'
                self.mycursor.execute(sqlFormula)
Exemplo n.º 4
0
    def checkTable(self, tableName):
        table = self.showTables()

        if (table is None or (not ms.inEqual(tableName, table))):
            return False
        else:
            return True
Exemplo n.º 5
0
    def createTableTextSize(self, tableName, fields):
        length = len(fields)
        tables = self.showTables()
        if (tables is None):
            string = ''

            for i in range(0, length):
                string = string + fields[i] + ' longtext ,'

            string = string[:-1]

            sqlFormula = sqlFormula = 'create table ' + tableName + '(' + string + ')'  #print(sqlFormula)

            self.mycursor.execute(sqlFormula)
            return True
        else:
            if (ms.inEqual(tableName, tables)):

                return False
            else:

                string = ''

                for i in range(0, length):
                    string = string + fields[i] + ' longtext ,'

                string = string[:-1]

                sqlFormula = 'create table ' + tableName + '(' + string + ')'  #print(sqlFormula)

                self.mycursor.execute(sqlFormula)
                return True
def inMultipleEqual(array1, array2):
    con = False
    for i in array1:
        if (ms.inEqual(i, array2)):
            con = True
            break

    return con
Exemplo n.º 7
0
def checkArrayEquality(array1, array2):
    val = False
    for i in array1:
        con = ms.inEqual(i, array2)
        if (con):
            val = True
            break
    return val
Exemplo n.º 8
0
def commonAllOut(array1, array2):
    val = []

    for i in array1:
        if (ms.inEqual(i, array2)):
            val.append(i)

    if (len(val) == 0):
        return None
    else:
        return val
Exemplo n.º 9
0
    def createOneColTable(self, tableName):
        tables = self.showTables()
        field = ['word']
        size = [100]
        if (tables is None):

            self.createTable(tableName, field, size)

        else:
            if (ms.inEqual(tableName, tables)):
                pass
            else:
                self.createTable(tableName, field, size)
Exemplo n.º 10
0
    def checkingWords(self, words):

        for i in words:
            first = i[0]
            data = self.selectAllData(first)
            #print(data,i)
            if (data == None):
                print('hii')
                return False
            elif (ms.inEqual(i, data)):
                return True
            else:
                return False
Exemplo n.º 11
0
    def getColName(self, tableName):
        sqlFormula = 'desc ' + tableName
        table = self.showTables()

        if (table is None or (not ms.inEqual(tableName, table))):
            return None
        else:

            self.mycursor.execute(sqlFormula)
            res = self.mycursor.fetchall()

            field = []
            for i in res:
                field.append(i[0])
            return field
Exemplo n.º 12
0
    def insertTwoInOne(self, word1, identity1, word2, identity2):
        tables = ms.makePair(identity1, identity2)
        dtable = self.showTables()

        outTables = ms.oddOut(dtable, tables)

        #Table is created

        if (len(outTables) == 0):
            pass
        else:

            for i in outTables:
                fields = ['word1', 'word2']
                size = [100, 100]
                self.createTable(i, fields, size)

        for i in tables:

            data = self.selectAllData(i)
            if (data == None):
                sqlFormula = 'insert into ' + i + ' values ("' + word1 + '","' + word2 + '")'
                self.mycursor.execute(sqlFormula)
            else:
                dic = ms.makeDictionary(data)

                d1 = []
                for ni in data:
                    d1.append(ni[0])

                if (ms.inEqual(word1, d1)):
                    wo = dic[word1]
                    if (ms.equalWord(wo, word2, trim=True)):
                        pass
                    else:
                        sqlFormula = 'insert into ' + i + ' values ("' + word1 + '","' + word2 + '")'
                        self.mycursor.execute(sqlFormula)
                else:
                    sqlFormula = 'insert into ' + i + ' values ("' + word1 + '","' + word2 + '")'
                    self.mycursor.execute(sqlFormula)