Migrating pile of script project to Django

Hi folks,

I have a project, which started out by writing some Python batch data migration scripts during learning Python (coming from Java, JavaScript mainly).

It includes:

  • a PostgreSQL DB with some 10 tables
  • some SqlAlchemy ORM mappings
  • a lot of hand written SQL
  • some internal modules interfacing some external systems by REST and GraphQl
  • some functionality relying on AWS SQS queues

It’s a mix of the big ball of mud pattern and some better refactored code. Things start to get better :smiley:
For sure the DB also needs some more normalisation and we really need a web GUI for some tasks and heavily lean towards learning Django for fast development.

Can someone recommend me good read about a project setup / folder structure to move my project over to a more sane architecture?
Or will it be enough to just move the scripts into some modules and call them from the web app backend code?

Thanks for your input!
Best,
Andreas

Any or all of the above.

I’d say the decision more depends upon whether or not you have any need / intention to maintain those modules outside the context of a Django application.

I definitely encourage you to build your web app using the standard directory structure, but external modules can be built however you find most useful.

If you still want to run any of these from the command line and not through a web application, I would suggest you become familiar with writing your own Django management commands. It’s an easy way for you to write command line scripts that still have access to, and take advantage of, the Django ORM.

Ken

Hi Ken,
thanks for your input! That’s more or less, what I hoped for.

The management commands sound interesting. I will check them out for sure!

Best,
Andreas