Exemplo n.º 1
0
def _report2():
    sliceEnv = SliceEnv()
    custDB = sliceEnv.open("CustDB")
    salseDB = sliceEnv.open("SalesDB")
    orderDB = sliceEnv.open("OrderDB")
    join_database = custDB.join(salseDB, "cust")
    if(join_database == None):
        return
    join_database = orderDB.join(salseDB, "order")
    if(join_database == None):
        return
    subprocess.check_call(["runhaskell", "report2"])
Exemplo n.º 2
0
def _runQuery():
    sliceEnv = SliceEnv()
    custDB = sliceEnv.open(_getInput('Enter Database Name'))
    if custDB == None:
        return
    columns = _getInput('Enter the list of columns to be displayed separated by the symbol "|"').split('|')
    conditionAttributes = _getInput('Enter the column, condition and the literal value separated by the symbol "|"').split('|')
    if(len(conditionAttributes) == 3):
        condition = SliceCondition(conditionAttributes[0], conditionAttributes[1], conditionAttributes[2])
    else:
        print 'Error: Condition format should be column_name|operation|literal_value'
        return
    custQuery = SliceQuery(columns, custDB, condition)
    sliceRecords = custDB.query(custQuery)
    if(sliceRecords == None):
        return
    output = " "
    for column in columns:
        output += column + "   "
    print output
    for record in sliceRecords:
        output = " "
        for column in columns:
            output += record._getValue(column) + "   " 
        print output
    sliceEnv.close("CustDB")
Exemplo n.º 3
0
def _bulkLoad():
    sliceEnv = SliceEnv()
    custDB = sliceEnv.open(_getInput('Enter Database Name'))
    if custDB == None:
        return
    print 'Only accepts file with .apd extension'
    custDB.load(_getInput('Enter Upload File Name (without .apd)'))
    sliceEnv.close("CustDB")
Exemplo n.º 4
0
def _displayJoin():
    sliceEnv = SliceEnv()
    custDB = sliceEnv.open(_getInput('Enter First Database Name'))
    if custDB == None:
        return
    salesDB = sliceEnv.open(_getInput('Enter Second Database Name'))
    if salesDB == None:
        return
    join_column = _getInput('Enter the join column')
    join_database = []
    if(join_column == ''):
        join_database = custDB.join(salesDB)
    else:
        join_database = custDB.join(salesDB, join_column)
    if(join_database != None):
        print "You can find the join database in the file " + custDB.name + salesDB.name + ".join"
    sliceEnv.close("SalesDB")
    sliceEnv.close("CustDB")
Exemplo n.º 5
0
def _updateRecord():
    sliceEnv = SliceEnv()
    custDB = sliceEnv.open(_getInput('Enter Database Name'))
    if custDB == None:
        return
    custRecord = custDB.createRecord()
    for field in custRecord.record:
        if custRecord.getFieldType(field[0], custDB.schema) ==  DBSlice.INT:
            custRecord.setInt(field[0], _processInteger('Enter ' + field[0]))
        elif custRecord.getFieldType(field[0], custDB.schema) ==  DBSlice.DOUBLE:
            custRecord.setDouble(field[0], _processFloat('Enter ' + field[0]))
        elif custRecord.getFieldType(field[0], custDB.schema) ==  DBSlice.STRING:
            custRecord.setString(field[0], _getInput('Enter ' + field[0]))
    custDB.update(custRecord)
    sliceEnv.close("CustDB")
Exemplo n.º 6
0
def _deleteRecord():
    sliceEnv = SliceEnv()
    custDB = sliceEnv.open(_getInput('Enter Database Name'))
    if custDB == None:
        return
    if custDB.index == None:
        print "Error: Cannot perform deletion on database without index"
        return
    keyValue = _processInteger('Enter ' + custDB.index)
    for i, record in enumerate(custDB.database):
        if int(record.getFieldValue(custDB.index)) == keyValue:
            custDB.database.pop(i)
            sliceEnv.close("CustDB")
            print "Record Deleted"
            return
        i = i + 1
    print "Error: Record does not exist"
Exemplo n.º 7
0
'''
Created on Aug 21, 2014
@author: Mehrdad Dehdashti
'''

from SliceDBMS.SliceEnv import SliceEnv
from SliceDBMS.SliceDB import SliceDB
from SliceDBMS.SliceRecord import SliceRecord

if __name__ == '__main__':
    
    sliceEnv = SliceEnv()
    custDB = sliceEnv.open("CustDB")
    
    custRecord = custDB.get(298)
    
    if(custRecord):
        print "Name " + custRecord.getString("name")
        print "Age " + custRecord.getInt("age")
        print "Address " + custRecord.getString("address")
    
    sliceEnv.close("CustDB")
Exemplo n.º 8
0
'''
Created on Aug 21, 2014
@author: Mehrdad Dehdashti
'''

from SliceDBMS.SliceEnv import SliceEnv
from SliceDBMS.SliceDB import SliceDB
from SliceDBMS.SliceRecord import SliceRecord

if __name__ == '__main__':

    sliceEnv = SliceEnv()
    custDB = sliceEnv.open("CustDB")
    salseDB = sliceEnv.open("SalesDB")

    joinList = custDB.join(salseDB)

    for record in joinList:
        name = record.getString("name")
        total = record.getDouble("total")
        print "Sales for " + name + ": " + total

    sliceEnv.close("SalesDB")
    sliceEnv.close("CustDB")