CognitiveScience commited on
Commit
d648e2f
1 Parent(s): c854dc6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -17
app.py CHANGED
@@ -31,7 +31,7 @@ from datasets import load_dataset
31
  #dataset = load_dataset("csv", data_files="./data.csv")
32
 
33
 
34
- DB_FILE = "./reviews.db"
35
 
36
  TOKEN = os.environ.get('HF_KEY')
37
 
@@ -49,7 +49,7 @@ repo.git_pull()
49
  #login(token=TOKEN2)
50
 
51
  # Set db to latest
52
- #shutil.copyfile("./data/reviews01.db", DB_FILE)
53
 
54
  # Create table if it doesn't already exist
55
 
@@ -70,19 +70,7 @@ except sqlite3.OperationalError:
70
  db.close()
71
 
72
  db = sqlite3.connect(DB_FILE)
73
- try:
74
- db.execute("SELECT * FROM reviews2").fetchall()
75
- #db.execute("SELECT * FROM reviews2").fetchall()
76
-
77
- db.close()
78
- except sqlite3.OperationalError:
79
- db.execute(
80
- '''
81
- CREATE TABLE reviews2 (id TEXT,
82
- title TEXT, link TEXT,channel TEXT, description TEXT, views INTEGER, uploaded TEXT, duration INTEGER, durationString TEXT)
83
- ''')
84
- db.commit()
85
- db.close()
86
  def get_latest_reviews(db: sqlite3.Connection):
87
  reviews = db.execute("SELECT * FROM reviews ORDER BY id DESC limit 100").fetchall()
88
  total_reviews = db.execute("Select COUNT(id) from reviews").fetchone()[0]
@@ -194,7 +182,7 @@ with gr.Blocks(css=css) as demo:
194
  load_data()
195
  #return "Hello " + name + "!"
196
  def backup_db():
197
- shutil.copyfile(DB_FILE, "./reviews1.db")
198
  db = sqlite3.connect(DB_FILE)
199
  reviews = db.execute("SELECT * FROM reviews").fetchall()
200
  pd.DataFrame(reviews).to_csv("./reviews.csv", index=False)
@@ -225,7 +213,7 @@ def backup_db_csv():
225
  # #return reviews, total_reviews
226
 
227
  scheduler1 = BackgroundScheduler()
228
- scheduler1.add_job(func=run_actr, trigger="interval", seconds=3600)
229
  scheduler1.start()
230
 
231
  scheduler2 = BackgroundScheduler()
 
31
  #dataset = load_dataset("csv", data_files="./data.csv")
32
 
33
 
34
+ DB_FILE = "./reviews1.db"
35
 
36
  TOKEN = os.environ.get('HF_KEY')
37
 
 
49
  #login(token=TOKEN2)
50
 
51
  # Set db to latest
52
+ shutil.copyfile("./reviews.db", DB_FILE)
53
 
54
  # Create table if it doesn't already exist
55
 
 
70
  db.close()
71
 
72
  db = sqlite3.connect(DB_FILE)
73
+
 
 
 
 
 
 
 
 
 
 
 
 
74
  def get_latest_reviews(db: sqlite3.Connection):
75
  reviews = db.execute("SELECT * FROM reviews ORDER BY id DESC limit 100").fetchall()
76
  total_reviews = db.execute("Select COUNT(id) from reviews").fetchone()[0]
 
182
  load_data()
183
  #return "Hello " + name + "!"
184
  def backup_db():
185
+ shutil.copyfile(DB_FILE, "./reviews.db")
186
  db = sqlite3.connect(DB_FILE)
187
  reviews = db.execute("SELECT * FROM reviews").fetchall()
188
  pd.DataFrame(reviews).to_csv("./reviews.csv", index=False)
 
213
  # #return reviews, total_reviews
214
 
215
  scheduler1 = BackgroundScheduler()
216
+ scheduler1.add_job(func=run_actr, trigger="interval", seconds=6)
217
  scheduler1.start()
218
 
219
  scheduler2 = BackgroundScheduler()