How do I delete everything from my replit database?

Hi, I have some garbage in my apps replit database. Is there a way to clear everything from the database, even if I can’t remember all the keys I used? Thanks!

run this in shell: replit nuke --i-am-sure

1 Like

Hey @IanTorweihe, welcome to the community!

Here’s how you’d do it in Python:

from replit import db

for key in db.keys(): del db[key]

And in Node.js:

const Database = require("@replit/database");
const db = new Database();

db.list().then(keys => {
	keys.forEach((key) => {
		db.delete(key);
	});
});
1 Like

In Python you can use db.clear()

1 Like

Hey @IanTorweihe welcome to the forums!

Im forgetting how to do this (if possible). But you can do db.getKeys() and loop over and delte all the keys

1 Like

BTW that’s not a joke, it’s an actual command

Wait @QwertyQwerty88’s was a joke? Now I am confused.

UMAR at home be like

I’m not joking BTW it’s an actual command you can run

No mine was not a joke, he was saying that his command was an actual command

Yeah but that isn’t going to clear the database is it?

this is the code snippet from __main__.py in the replit package that handles CLI:

@cli.command(name="nuke")
@click.option("--i-am-sure", is_flag=True)
def nuke_db(i_am_sure: bool) -> None:
    """Wipe ALL key-value pairs in the DB."""
    if i_am_sure:
        click.echo(info("Beginning Nuke operation...\n"))
        keys = list(database.keys())

        for k in keys:
            del database[k]

        click.echo(success("Nuke operation successful."))
    else:
        click.echo(
            failure(
                "If you REALLY want to delete everything in your database, "
                "run again with the --i-am-sure flag."
            )
        )