forked from arXiv/arxiv-filemanager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopulate_test_database.py
More file actions
23 lines (17 loc) · 844 Bytes
/
populate_test_database.py
File metadata and controls
23 lines (17 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""Helper script to initialize the Upload database and add a few rows."""
from datetime import datetime
import click
from filemanager.factory import create_web_app
from filemanager.services import uploads
app = create_web_app()
app.app_context().push()
@app.cli.command()
def populate_database():
"""Initialize the search index."""
uploads.db.create_all()
uploads.db.session.add(uploads.DBUpload(name='The first upload', created_datetime=datetime.now(UTC),submission_id='1234567'))
uploads.db.session.add(uploads.DBUpload(name='The second upload', created_datetime=datetime.now(UTC),submission_id='1234568'))
uploads.db.session.add(uploads.DBUpload(name='The third upload', created_datetime=datetime.now(UTC),submission_id='1234569'))
uploads.db.session.commit()
if __name__ == '__main__':
populate_database()