Skip to content

Commit

Permalink
adding support for export in legacy db schema [for the old tinydb]
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyBRoswell committed Dec 4, 2024
1 parent 66d570f commit ee76a66
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
19 changes: 19 additions & 0 deletions vreapis/catalog/management/commands/export_in_legacy_db_schema.py
Original file line number Diff line number Diff line change
@@ -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")
4 changes: 2 additions & 2 deletions vreapis/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -20,5 +20,5 @@ def main():


if __name__ == '__main__':
dotenv.read_dotenv()
# dotenv.read_dotenv()
main()
1 change: 1 addition & 0 deletions vreapis/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ee76a66

Please sign in to comment.