File size: 612 Bytes
ce5a4ba | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #!/usr/bin/env python3
"""Materialize the x-lite seed JSON into SQLite during Docker build."""
import os
import sys
APP_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
if APP_DIR not in sys.path:
sys.path.insert(0, APP_DIR)
import app as x_lite_app # noqa: E402
def main():
db_path = x_lite_app.DB_PATH
if os.path.exists(db_path):
os.remove(db_path)
with x_lite_app.app.app_context():
x_lite_app.init_db()
size_mb = os.path.getsize(db_path) / (1024 * 1024)
print(f"Wrote {db_path} ({size_mb:.1f} MB)")
if __name__ == "__main__":
main()
|