Esempio n. 1
0
def getTableEntryById(category, targetId):
    
    executeString = "SELECT * FROM {0} WHERE id = {1}".format(category, targetId)
    try:
        cur = con.cursor(cursor_factory=psycopg2.extras.DictCursor)    
        cur.execute(executeString)
        
        row = cur.fetchone()
        if row is not None:            
            return dict(row)
        else:
            return None
        #for index in row.keys():
            #entry[index] = copy.deepcopy(row[index])
             
    except psycopg2.DatabaseError, e:
        print 'Error %s' % e    
        sys.exit(1)
Esempio n. 2
0
def getTableEntryById(category, targetId):

    executeString = "SELECT * FROM {0} WHERE id = {1}".format(
        category, targetId)
    try:
        cur = con.cursor(cursor_factory=psycopg2.extras.DictCursor)
        cur.execute(executeString)

        row = cur.fetchone()
        if row is not None:
            return dict(row)
        else:
            return None
        #for index in row.keys():
        #entry[index] = copy.deepcopy(row[index])

    except psycopg2.DatabaseError, e:
        print 'Error %s' % e
        sys.exit(1)
Esempio n. 3
0
def updateTurtleConsensus(turtleId, consensus):
    
    category = TurtleTable
    turtle = getTableEntryById(category, turtleId)
    
    if not turtle:
        abort(404)
    
    try:
        cur = con.cursor(cursor_factory=psycopg2.extras.DictCursor)   
        
        executePushString = "UPDATE {0} SET {1} = {2} WHERE id = {3}".format(category, 'consensus', consensus, turtleId)
        
        cur.execute(executePushString)
        con.commit()
            
    except psycopg2.DatabaseError, e:
        print 'Error %s' % e    
        sys.exit(1)
Esempio n. 4
0
def updateTurtleConsensus(turtleId, consensus):

    category = TurtleTable
    turtle = getTableEntryById(category, turtleId)

    if not turtle:
        abort(404)

    try:
        cur = con.cursor(cursor_factory=psycopg2.extras.DictCursor)

        executePushString = "UPDATE {0} SET {1} = {2} WHERE id = {3}".format(
            category, 'consensus', consensus, turtleId)

        cur.execute(executePushString)
        con.commit()

    except psycopg2.DatabaseError, e:
        print 'Error %s' % e
        sys.exit(1)