Spaces:
Runtime error
Runtime error
Commit
·
86c77f9
1
Parent(s):
2274ab7
Update app.py
Browse files
app.py
CHANGED
|
@@ -77,8 +77,8 @@ from datasets import load_dataset
|
|
| 77 |
def get_latest_reviews(): #db: sqlite3.Connection):
|
| 78 |
#reviews = db.execute("SELECT * FROM reviews ORDER BY id DESC limit 100").fetchall()
|
| 79 |
#total_reviews = db.execute("Select COUNT(id) from reviews").fetchone()[0]
|
| 80 |
-
|
| 81 |
-
|
| 82 |
return reviews, total_reviews
|
| 83 |
|
| 84 |
#def get_latest_reviews2(db: sqlite3.Connection):
|
|
@@ -104,9 +104,10 @@ def ccogsphere(name: str, rate: int, celsci: str):
|
|
| 104 |
print(view, duration)
|
| 105 |
#celsci=celsci+celsci2
|
| 106 |
cursor.execute("INSERT INTO reviews(name, view, duration) VALUES(?,?,?)", [celsci+" Video #"+str(index+1), view, duration])
|
| 107 |
-
db.commit()
|
| 108 |
-
|
| 109 |
-
|
|
|
|
| 110 |
#db.close()
|
| 111 |
r = requests.post(url='https://ccml-persistent-data2.hf.space/api/predict/', json={"data": [celsci + " ", celsci2]})
|
| 112 |
|
|
@@ -137,7 +138,7 @@ def run_ecs(inp):
|
|
| 137 |
except: # sqlite3.OperationalError:
|
| 138 |
print ("db error")
|
| 139 |
|
| 140 |
-
df=df.drop(df.columns[4], axis=1)
|
| 141 |
|
| 142 |
#db = sqlite3.connect(DB_FILE)
|
| 143 |
#cursor = db.cursor()
|
|
@@ -145,7 +146,7 @@ def run_ecs(inp):
|
|
| 145 |
#df.to_sql('reviews2', db, if_exists='replace', index=False)
|
| 146 |
|
| 147 |
#db.commit()
|
| 148 |
-
reviews2, total_reviews2 = get_latest_reviews(db)
|
| 149 |
#db.close()
|
| 150 |
#print ("print000", total_reviews2,reviews2)
|
| 151 |
return reviews2, total_reviews2
|
|
|
|
| 77 |
def get_latest_reviews(): #db: sqlite3.Connection):
|
| 78 |
#reviews = db.execute("SELECT * FROM reviews ORDER BY id DESC limit 100").fetchall()
|
| 79 |
#total_reviews = db.execute("Select COUNT(id) from reviews").fetchone()[0]
|
| 80 |
+
reviews = reviews.DataFrame(reviews, columns=["id", "date_created", "name", "view", "duration"])
|
| 81 |
+
total_reviews=df.count()[0]
|
| 82 |
return reviews, total_reviews
|
| 83 |
|
| 84 |
#def get_latest_reviews2(db: sqlite3.Connection):
|
|
|
|
| 104 |
print(view, duration)
|
| 105 |
#celsci=celsci+celsci2
|
| 106 |
cursor.execute("INSERT INTO reviews(name, view, duration) VALUES(?,?,?)", [celsci+" Video #"+str(index+1), view, duration])
|
| 107 |
+
#db.commit()
|
| 108 |
+
reviews=df
|
| 109 |
+
total_reviews=df.count()[0]
|
| 110 |
+
#reviews, total_reviews = get_latest_reviews(db)
|
| 111 |
#db.close()
|
| 112 |
r = requests.post(url='https://ccml-persistent-data2.hf.space/api/predict/', json={"data": [celsci + " ", celsci2]})
|
| 113 |
|
|
|
|
| 138 |
except: # sqlite3.OperationalError:
|
| 139 |
print ("db error")
|
| 140 |
|
| 141 |
+
#df=df.drop(df.columns[4], axis=1)
|
| 142 |
|
| 143 |
#db = sqlite3.connect(DB_FILE)
|
| 144 |
#cursor = db.cursor()
|
|
|
|
| 146 |
#df.to_sql('reviews2', db, if_exists='replace', index=False)
|
| 147 |
|
| 148 |
#db.commit()
|
| 149 |
+
#reviews2, total_reviews2 = get_latest_reviews(db)
|
| 150 |
#db.close()
|
| 151 |
#print ("print000", total_reviews2,reviews2)
|
| 152 |
return reviews2, total_reviews2
|