Example #1
0
def copyContentData(boxID, localdb, clouddb):
    cloud = clouddb.connect()
    local = localdb.connect()

    # GET DATA
    sql = "SELECT * from eisvillageserver.files WHERE boxID =" + str(boxID)
    rows = cloud.execute(sql)
    for row in rows:
        local.execute(files.insert().values(**row))

    resetDownloadCountSynced(localdb);

    sql = "SELECT UID from files"
    rows = local.execute(sql);

    for row in rows:
        s3t.downloadKey(row[0]);

    updateLastSynced(boxID, clouddb)

    return
Example #2
0
def pullContentData(boxID, localdb, clouddb):
    lastSynced = getLastSyncedDate(boxID, clouddb)
    cloud = clouddb.connect()
    local = localdb.connect()

    sql = "SELECT * from eisvillageserver.files WHERE LastUpdated >= '" + lastSynced.strftime(f) + "' AND BoxID = " + str(boxID)

    result = cloud.execute(sql);

    for row in result:
        old = "SELECT 'S3URI' from files WHERE UID = '{0}'".format(row[0])
        olddata = local.execute(old)


        insert = "INSERT OR REPLACE INTO files ('UID', 'Title', 'Description', 'DateUploaded', 'S3URI', 'Category', 'Language', 'Country', 'DownloadCount', 'LastUpdated', 'DownloadCountSynced', 'BoxID')"
        insert += "VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}')".format(row[0], row[1], row[2], row[3].strftime(f), row[4], row[5], row[6], row[7], row[8], row[9].strftime(f), 0, boxID)

        update = "update files set 'Title' = '{0}', 'Description' = '{1}', 'S3URI' = '{2}', 'Category' = '{3}' WHERE (UID = '{4}')".format(row[1], row[2], row[4], row[5], row[0])

        print insert
        #print update

        inserted = local.execute(insert);
        updated = local.execute(update);

        if (olddata != row[4] or not olddata): #if s3uri's don't match
            print row[0]
            s3t.downloadKey(row[0]);

        #updated = local.execute(update);


        #local.execute(sql)
    updateLastSynced(boxID, clouddb)

    return