Code Room
Code reviewMedium
Question
Review this Python nightly database backup job.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
import subprocess, datetime def nightly_backup(db_url, bucket): name = f"backup-{datetime.date.today()}.sql.gz" cmd = f"pg_dump {db_url} | gzip > /tmp/{name}" subprocess.run(cmd, shell=True) upload(bucket, f"/tmp/{name}") alert("Backup completed successfully")Run or narrate your approach, then ask the coach.