Better replit db in flask not syncing with replit db

Hello, I could not find a lot on this module called better replit db, but it was suggested to me in my last question.
It is a lot faster than the actual replit db, but it does not sync with the database when the app is restarted. I am using it for my Python Flask project called Pixel Board.
I tried running print(db) and it shows the URL of my repl database, but it only seems to be able to add keys instead of being able to remove keys or get keys when the app is restarted or booted up.
Does anyone know how to fix this?
Repl link:
Server code:

import os
from flask import Flask, render_template
from flask_socketio import SocketIO, emit
from betterreplitdb import db
app = Flask(__name__)
socketio = SocketIO(app)
app.config['TEMPLATES_AUTO_RELOAD'] = True #if true, it auto reloads templates if a change is made to them
app.secret_key = os.environ['SECRET_KEY'] #The secret key
board_size = 60 #The size of the pixel board (Warning: A very large size may either break the app or overload repl db)
keys = db.keys() #Gets the keys
def index():
    """The index page (Board is on it)"""    
    return render_template('index.html', size=board_size, db=db)
"""Socketio events"""
def change_pixel(pixel):
  db.set(pixel['Pixel'], pixel['Pixel']) #put the pixel in the database
  emit('change_pixel', {'Pixel': pixel['Pixel'], 'Color': pixel['Color']}, broadcast=True), host='')

Are you using deployments by any chance?

Im not using deployments

Looking at this,

it says 2021, might not be up to date. You might have to stick with the regular replit db

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.