Rather than adding one element at a time, consider batch loading to improve performance.
Run in CI
rules: - id: batch-import pattern: | for $X in $Y: db.session.add($Z) message: Rather than adding one element at a time, consider batch loading to improve performance. languages: - python severity: WARNING metadata: category: performance technology: - sqlalchemy license: Commons Clause License Condition v1.0[LGPL-2.1-only]
# ruleid:batch-import for song in songs: db.session.add(song) # ruleid:len-all-count len(persons.all())
Short Link: https://sg.run/PprN