Пример #1
0
def put_rand_ddb(event, context):
    gw = apigw(event, context)
    rand_table_name = os.environ['RAND_TABLE_NAME']
    rand = random.randint(0, max)
    table = dynamodb.Table(rand_table_name)
    item = {'rand': rand}
    table.put_item(Item=item)
    return gw.ok("random number " + str(rand) + " put to table " +
                 rand_table_name)
Пример #2
0
def put_rand_rdb(event, context):
    gw = apigw(event, context)
    rand = random.randint(0, max)
    db_host = os.environ['DB_HOST']
    conn = mysql.connector.connect(host=db_host,
                                   user="******",
                                   passwd="Masterkey123")
    print(conn)
    cursor = conn.cursor()
    cursor.execute("create database if not exists sducks")
    cursor.execute(
        "create table if not exists sducks.rands(rand integer primary key)")
    sql = "insert into sducks.rands(rand) values (%(rand)s)"
    params = {'rand': rand}
    cursor.execute(sql, params)
    conn.commit()
    cursor.close()
    conn.close()
    return gw.ok("Inserted " + str(rand) + " to endpoint " + db_host)
Пример #3
0
def fibo_memo(event, context):
    gw = apigw(event, context)
    return fib_memo(gw)
Пример #4
0
def fibo_gen(event, context):
    gw = apigw(event, context)
    return fib_gen(gw)
Пример #5
0
def fibo_rec(event, context):
    gw = apigw(event, context)
    return fib_rec(gw)
Пример #6
0
def fibo_iter(event, context):
    gw = apigw(event, context)
    return fib_iter(gw)
Пример #7
0
def hello(event, context):
    gw = apigw(event, context)
    return gw.ok("Hello World!")