Example #1
0
def createaccount():
    '''
    This method creates an entry in the user table.
    TODO - It should eventually be replaced with a
    a generic insert function
    '''
    #Retrieve parameters
    user = request.args.get('user')
    passwd = request.args.get('passwd')
    uniqueId = request.args.get('id')
    if (user == None):
        user = False
    if (passwd == None):
        passwd = False

    handler = SQLiteHandler('PM-Web.db')
    var = ""
    if (user == False and passwd == False):
        #return str(handler.selectFromTable('UserTable', '*'))
        return str("-1")
    try:
        handler.insertIntoTable(
            'UserTable',
            'firstname,lastname,email,password,bio,projectlist,picture',
            'null,null,"' + user + '","' + passwd + '",null,null,null')
    except:
        return '1 - User already exists in database'

    return '0 - User added to database'
Example #2
0
def insert():
    '''
    This route is going to insert a value into an input table.
    This value will be a row, and syntax must be valid SQL syntax
    for this operation to complete.

    @param SQLString
    @param table
    '''
    valueString = request.args.get('valuestring')
    columnString = request.args.get('columnstring')
    table = request.args.get('table')

    if (valueString == None or table == None or columnString == None):
        return "2"

    handler = SQLiteHandler('PM-Web.db')

    print table, columnString, valueString

    try:
        handler.insertIntoTable(table, columnString, valueString)
    except:
        return "0"

    # Otherwise
    return "1"