0

I have a python script which downloads data from an API source and transforms it in to a a list of dictionaries that I save as a JSON file.

Separately, I have a Django project that uses this data to serve the data in a web page. I am currently using the default SQLite DB but plan on using Postgresql in production.

The data is updated frequently, and so the script needs to download the new data on a daily basis and update the data being used by the Djano project's database.

The issue is I can make the Django project "work" with dummy, sample data; and the script works independently of Django.

How do I integrate this downloading script to work with Django and "push" new records and updates to the Django DB using the python script? Users of the Django project will only read the data and not write / update the data otherwise.

I have reviewed a variety of tutorials such as the Django polls app but am lost on how to marry these two pieces together. Is this a case of using fixtures over and over against to reload data into the DB? It appears that this is not the best method as fixtures are only used for test data and would not be automatic.

What am I missing? Alternatively, is Django not the best way to serve data from a DB that is read-only? What would be a better alternative?

2 Answers 2

1

One way to approach this is following:

Sign up to request clarification or add additional context in comments.

1 Comment

This makes sense. I was thinking of using Cron, but did not realise that you could create custom commands under manage.py . Will give this a go.
0

Check out this answer. You have done most of the work already. There's a number of ways you could approach inserting your JSON values into your database. You don't even have to go through Django if you don't want to. All that matters is that your data ends up in the database somehow. Django doesn't have to be the one inserting those values to use them either, it can read values placed in the database by 3rd parties.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.