コード例 #1
0
ファイル: select.py プロジェクト: jango2015/PyDB
    def join(self, table1, table2, selection1, selection2, cond):
        ctlg1 = catalogCore()
        ctlg1.loadCatalog(table1)
        ctlg2 = catalogCore()
        ctlg2.loadCatalog(table2)
        pgmg = pageManager()
        io_s = general()
        cond1pos = -1
        cond2pos = -1

        for x in range(len(ctlg1.catalog)):
            if ctlg1.catalog[x][0] == cond:
                cond1pos = x

        for x in range(len(ctlg2.catalog)):
            if ctlg2.catalog[x][0] == cond:
                cond2pos = x

        joinedVals = []
        for x in selection1:
            for y in selection2:
                if x[1][cond1pos] == y[1][cond2pos]:
                    newv = []
                    newv.extend(x[1])
                    newv.extend(y[1])
                    joinedVals.append(newv)
                    print(newv)
        return joinedVals
コード例 #2
0
ファイル: select.py プロジェクト: MauricioTorre/PyDB
    def join(self, table1, table2, selection1, selection2, cond):
        ctlg1 = catalogCore()
        ctlg1.loadCatalog(table1)
        ctlg2 = catalogCore()
        ctlg2.loadCatalog(table2)
        pgmg = pageManager()
        io_s = general()
        cond1pos = -1
        cond2pos = -1

        for x in range(len(ctlg1.catalog)):
            if ctlg1.catalog[x][0] == cond:
                cond1pos = x

        for x in range(len(ctlg2.catalog)):
            if ctlg2.catalog[x][0] == cond:
                cond2pos = x

        joinedVals = []
        for x in selection1:
            for y in selection2:
                if x[1][cond1pos] == y[1][cond2pos]:
                    newv = []
                    newv.extend(x[1])
                    newv.extend(y[1])
                    joinedVals.append(newv)
                    print(newv)
        return joinedVals
コード例 #3
0
ファイル: select.py プロジェクト: MauricioTorre/PyDB
    def selection(self, table, values, function = None, newValues = None):
        ctlg = catalogCore()
        ctlg.loadCatalog(table)

        pgmg = pageManager()
        io_s = general()
        print("Values not verified.")

        vals = self.buildValues(ctlg)
        newVals = None
        if newValues is not None:
            newVals = self.buildValues(ctlg)
            for x in range(len(newValues)):
                for y in range(len(ctlg.catalog)):
                    val1 = newValues[x][0]
                    val2 = ctlg.catalog[y][0]
                    if val1 == val2:
                        newVals[y] = newValues[x][1]

        for x in range(len(values)):
            for y in range(len(ctlg.catalog)):
                print("VER: " + str(ctlg.catalog[y][0]))
                val1 = str(values[x][0]).replace("'", "")
                val2 = str(ctlg.catalog[y][0]).replace("'", "")
                if values[x][1] == '=':
                    if val1 == val2:
                        vals[y] = values[x][2].replace("'", "")
                else:
                    print ("NO OPERATOR #322")

        print("VALS: " + str(vals))
        x = pgmg.readValues(table, vals, function, newVals)
        return x
        print(len(x))
コード例 #4
0
ファイル: select.py プロジェクト: jango2015/PyDB
    def selection(self, table, values, function=None, newValues=None):
        ctlg = catalogCore()
        ctlg.loadCatalog(table)

        pgmg = pageManager()
        io_s = general()
        print("Values not verified.")

        vals = self.buildValues(ctlg)
        newVals = None
        if newValues is not None:
            newVals = self.buildValues(ctlg)
            for x in range(len(newValues)):
                for y in range(len(ctlg.catalog)):
                    val1 = newValues[x][0]
                    val2 = ctlg.catalog[y][0]
                    if val1 == val2:
                        newVals[y] = newValues[x][1]

        for x in range(len(values)):
            for y in range(len(ctlg.catalog)):
                val1 = values[x][0]
                val2 = ctlg.catalog[y][0]
                if val1 == val2:
                    vals[y] = values[x][1]

        x = pgmg.readValues(table, vals, function, newVals)
        return x
        print(len(x))
コード例 #5
0
ファイル: select.py プロジェクト: CaballoSinNombre/PyDB
    def selection(self, table, values, function = None, newValues = None):
        ctlg = catalogCore()
        ctlg.loadCatalog(table)

        pgmg = pageManager()
        io_s = general()
        print("Values not verified.")

        vals = self.buildValues(ctlg)
        newVals = None
        if newValues is not None:
            newVals = self.buildValues(ctlg)
            for x in range(len(newValues)):
                for y in range(len(ctlg.catalog)):
                    val1 = newValues[x][0]
                    val2 = ctlg.catalog[y][0]
                    if val1 == val2:
                        newVals[y] = newValues[x][1]

        for x in range(len(values)):
            for y in range(len(ctlg.catalog)):
                val1 = values[x][0]
                val2 = ctlg.catalog[y][0]
                if val1 == val2:
                    vals[y] = values[x][1]


        x = pgmg.readValues(table, vals, function, newVals)
        return x
        print(len(x))
コード例 #6
0
    def selection(self, table, values):
        ctlg = catalogCore()
        ctlg.loadCatalog(table)
        pgmg = pageManager()
        io_s = general()
        print("Values not verified.")

        pgmg.readValues(table)
コード例 #7
0
def main():
    print ("dsad")

    io = general()
    #io.initPage(2)
    io.write()



    eval = evaluator()
    eval.execute(
        """
        create table table_name
        (
        column_name1 data_type(size),
        column_name2 data_type(size),
        column_name3 data_type(size),
        );
        """

    )



    tblm = manager()
    tblm.createTable("students2", [["id", "integer"], ["phone", "string"]])


    ctlg2 = catalogCore()
    ctlg2.loadCatalog("students2")
    ctlg2.printCtlg()


    ins = insert()

    #ins.insertRecord("students2", ["26", "terce32441iro"])
    #for x in range(25, 82):
    #    ins.insertRecord("students3", [str(x), "terce3PG32323o" + str(x)])

    sel = select()
    upd = update()
    #sel.selection("students2", [])
    upd.update("students2", [['phone', 'terceiro2221see']], [['phone', 'terceiro2221seesss']])
    sel.selection("students2", [['phone', 'terce32441iro']])
    print("321-----")
    #sel.selection("students2", [])
    #sel.selection("students3", [])
    #sel.join("students2", "students3", sel.selection("students2", []), sel.selection("students3", []), "id")
    main_pool.forceBuffer()
    print(main_pool.pool)

    from query.parser.sqlparse import parser
    pt = parser()
    #print(pt.parse("select * from x where x = 3 and y = 9"))
    #eval.execQuery("insert into students2 values (\"83\", \"gravado\")")
    print("select")
    eval.execQuery("select * from students2 where phone = 'gravado'") #where phone = terce32441iro
コード例 #8
0
ファイル: main.py プロジェクト: MauricioTorre/PyDB
def main():
    print ("dsad")

    io = general()
    #io.initPage(2)
    io.write()



    eval = evaluator()
    eval.execute(
        """
        create table table_name
        (
        column_name1 data_type(size),
        column_name2 data_type(size),
        column_name3 data_type(size),
        );
        """

    )



    tblm = manager()
    tblm.createTable("students2", [["id", "integer"], ["phone", "string"]])


    ctlg2 = catalogCore()
    ctlg2.loadCatalog("students2")
    ctlg2.printCtlg()


    ins = insert()

    #ins.insertRecord("students2", ["26", "terce32441iro"])
    #for x in range(25, 82):
    #    ins.insertRecord("students3", [str(x), "terce3PG32323o" + str(x)])

    sel = select()
    upd = update()
    #sel.selection("students2", [])
    upd.update("students2", [['phone', 'terceiro2221see']], [['phone', 'terceiro2221seesss']])
    sel.selection("students2", [['phone', 'terce32441iro']])
    print("321-----")
    #sel.selection("students2", [])
    #sel.selection("students3", [])
    #sel.join("students2", "students3", sel.selection("students2", []), sel.selection("students3", []), "id")
    main_pool.forceBuffer()
    print(main_pool.pool)

    from query.parser.sqlparse import parser
    pt = parser()
    #print(pt.parse("select * from x where x = 3 and y = 9"))
    #eval.execQuery("insert into students2 values (\"83\", \"gravado\")")
    print("select")
    eval.execQuery("select * from students2 where id = '26'") #where phone = terce32441iro
コード例 #9
0
ファイル: insert.py プロジェクト: MauricioTorre/PyDB
 def insertRecord(self, table, values):
     ctlg = catalogCore()
     ctlg.loadCatalog(table)
     io_s = general()
     print("Values not verified.")
     if len(ctlg.catalog) == len(values):
         pgmg = pageManager()
         pgmg.writeValue(table, values)
     else:
         print("Number of values does not match table columns")
コード例 #10
0
 def insertRecord(self, table, values):
     ctlg = catalogCore()
     ctlg.loadCatalog(table)
     io_s = general()
     print("Values not verified.")
     if len(ctlg.catalog) == len(values):
         pgmg = pageManager()
         pgmg.writeValue(table, values)
     else:
         print("Number of values does not match table columns")
コード例 #11
0
ファイル: evaluator.py プロジェクト: CaballoSinNombre/PyDB
    def execute(self, query):
        if ("create table") in query:
            createTbl = r"(?:\s*)create table(?:\s*)(.*?)(?:\s*)\((?:\s*)(.*?)\);"
            groups =  re.findall(createTbl, query, re.S)
            print ("----->" + str(groups))
            attribsre = r"((?:.*?) (?:.*?),(?:\s*))"
            attribs = re.findall(attribsre, groups[0][1], re.S)
            print ("----->" + str(attribs))
            ctrl = catalogCore()
            ctrl.newCatalog(groups[0][0])
            for x in attribs:
                attr = x.split(" ")
                ctrl.insertAttr(attr[0], attr[1].replace(",", "").replace("\n", ""))

            ctrl.commitCatalog()
コード例 #12
0
    def execute(self, query):
        if ("create table") in query:
            createTbl = r"(?:\s*)create table(?:\s*)(.*?)(?:\s*)\((?:\s*)(.*?)\);"
            groups = re.findall(createTbl, query, re.S)
            print("----->" + str(groups))
            attribsre = r"((?:.*?) (?:.*?),(?:\s*))"
            attribs = re.findall(attribsre, groups[0][1], re.S)
            print("----->" + str(attribs))
            ctrl = catalogCore()
            ctrl.newCatalog(groups[0][0])
            for x in attribs:
                attr = x.split(" ")
                ctrl.insertAttr(attr[0], attr[1].replace(",",
                                                         "").replace("\n", ""))

            ctrl.commitCatalog()
コード例 #13
0
ファイル: main.py プロジェクト: BernardoGO/test
io.write()

eval = evaluator()
eval.execute(
    """
    create table table_name
    (
    column_name1 data_type(size),
    column_name2 data_type(size),
    column_name3 data_type(size),
    );
    """

)

tblm = manager()
tblm.createTable("students2", [["id", "integer"], ["phone", "string"]])


ctlg2 = catalogCore()
ctlg2.loadCatalog("students2")
ctlg2.printCtlg()

from query.commands.insert import *
from query.commands.select import *

ins = insert()
#ins.insertRecord("students2", ["24", "terce321iro"])

sel = select()
sel.selection("students2", [])
コード例 #14
0
 def createTable(self, name, attrs):
     ctlg = catalogCore()
     ctlg.tableName = name
     for x in attrs:
         ctlg.insertAttr(x[0], x[1])
     ctlg.commitCatalog()
コード例 #15
0

io = general()
#io.initPage(2)
io.write()

eval = evaluator()
eval.execute("""
    create table table_name
    (
    column_name1 data_type(size),
    column_name2 data_type(size),
    column_name3 data_type(size),
    );
    """)

tblm = manager()
tblm.createTable("students2", [["id", "integer"], ["phone", "string"]])

ctlg2 = catalogCore()
ctlg2.loadCatalog("students2")
ctlg2.printCtlg()

from query.commands.insert import *
from query.commands.select import *

ins = insert()
#ins.insertRecord("students2", ["24", "terce321iro"])

sel = select()
sel.selection("students2", [])
コード例 #16
0
ファイル: tablemgr.py プロジェクト: MauricioTorre/PyDB
 def createTable(self, name, attrs):
     ctlg = catalogCore()
     ctlg.tableName = name
     for x in attrs:
         ctlg.insertAttr(x[0], x[1])
     ctlg.commitCatalog()