I have a function like the following that I want to use to compute the hash of a sqlite database file, in order to compare it to the last backup I made to detect any changes.
def get_hash(file_path):
    # http://stackoverflow.com/a/3431838/1391717
    hash_sha1 = hashlib.sha1
    with open(file_path, "rb") as f:
        for chunk in iter(lambda: f.read(4096), b""):
            hash_sha1.update(chunk)
    return hash_sha1.hexdigest()
I plan on locking the database, so no one can write to it while I'm computing the hash. Is it possible for me to cause any harm while doing this?
// http://codereview.stackexchange.com/questions/78643/create-sqlite-backups
connection = sqlite3.connect(database_file)
cursor = connection.cursor()
cursor.execute("begin immediate")
db_hash = get_hash(args.database)
 
    