Replit database with Reserved VM

I had a Discord bot with Always On, using the Replit database. Obviously that is no longer an option, so I’ve moved over to Core (despite my reservations), and anything that was using the database no longer works.
Is there a workaround for this, or what is the solution - what database should I use instead?

Hey, @segowner!
What isn’t working? Do you have any errors?

2 Likes

Please ensure that you are using v3.3.0 or higher of the replit package:

https://docs.replit.com/hosting/databases/replit-database#importing-the-database

2 Likes

There are no errors, but it’s as though the database isn’t there. I’ve not changed any of the code from when it was Always On.
I’ve also tried using PostgreSQL, but there appears to be no permanence there either - I’ve written some some code to test it by creating a simple Discord command to create a table, which works. But then another command to insert gives the error “psycopg2.errors.UndefinedTable: relation “users” does not exist”, but it does!

Actually, I’ve found this. This line of code

db["ladder" + str(newmessageid)] = [userid, str(createdat), []]

generates the error:

TypeError: 'NoneType' object does not support item assignment

These precedes that line:

userid = str(message.author.id)
createdat = newmessage.created_at

This code has worked in the past.

2 Likes

It’s using v3.6.1 according to the packages tab, but pip show replit is showing v3.2.4

2 Likes

try using pip install --upgrade replit instead of using the packages tab, as they use different methods i think

1 Like

Thanks - I did that and it looks like it has installed to v3.3.1 but the problem is still there

1 Like

Maybe something is weird with your template… try the following

pip uninstall replit
poetry remove replit
poetry lock
pip install replit==3.3.1

Or create a new repl using the latest template and port your code over

Hi. I did that and now I get the following error message when running the code:

Using version ^3.6.1 for replit

Updating dependencies
Resolving dependencies...

  SolverProblemError

  The current project's Python requirement (>=3.8.0,<3.9) is not compatible with some of the required packages Python requirement:
    - replit requires Python >=3.9,<4.0, so it will not be satisfied for Python >=3.8.0,<3.9
  
  Because no versions of replit match >3.6.1,<4.0.0
   and replit (3.6.1) requires Python >=3.9,<4.0, replit is forbidden.
  So, because python-template depends on replit (^3.6.1), version solving failed.

in your pyproject.toml next to python, change (3.8) to (3.9)