From ee76a6692d509441383be3bcd43c599016da1ace Mon Sep 17 00:00:00 2001 From: Andy Bayer Roswell Date: Wed, 4 Dec 2024 19:55:23 +0100 Subject: [PATCH] adding support for export in legacy db schema [for the old tinydb] --- .../commands/export_in_legacy_db_schema.py | 19 +++++++++++++++++++ vreapis/manage.py | 4 ++-- vreapis/requirements.txt | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 vreapis/catalog/management/commands/export_in_legacy_db_schema.py diff --git a/vreapis/catalog/management/commands/export_in_legacy_db_schema.py b/vreapis/catalog/management/commands/export_in_legacy_db_schema.py new file mode 100644 index 0000000..ccd6013 --- /dev/null +++ b/vreapis/catalog/management/commands/export_in_legacy_db_schema.py @@ -0,0 +1,19 @@ +from django.core.management import CommandParser +from django.core.management.base import BaseCommand, CommandError +from catalog.models import Cell + +class Command(BaseCommand): + help = 'Export designated tables in legacy db schema' + + + def add_arguments(self, parser: CommandParser): + parser.add_argument('tables', type=str, nargs='+', help='Tables to export') + + def handle(self, *args, **options): + for table in options['tables']: + match table: + case 'Cell': + queryset = Cell.objects.all() + print(queryset) + case _: + raise CommandError(f"Table {table} is not supported") diff --git a/vreapis/manage.py b/vreapis/manage.py index 88ef4fb..4b3bc63 100755 --- a/vreapis/manage.py +++ b/vreapis/manage.py @@ -2,7 +2,7 @@ """Django's command-line utility for administrative tasks.""" import os import sys -import dotenv +# import dotenv # always complains `No module named 'dotenv'` I don't know why def main(): @@ -20,5 +20,5 @@ def main(): if __name__ == '__main__': - dotenv.read_dotenv() + # dotenv.read_dotenv() main() diff --git a/vreapis/requirements.txt b/vreapis/requirements.txt index b4b813b..66fd927 100644 --- a/vreapis/requirements.txt +++ b/vreapis/requirements.txt @@ -7,6 +7,7 @@ gunicorn==21.2.0 pyyaml==6.0.1 requests==2.31.0 django-dotenv==1.4.2 +# python-dotenv==1.0.1 django-cors-headers==4.3.1 django-extensions==3.2.3 psycopg2==2.9.9