Fetching API data in json format and inserting it into the django local database.

523 views
Skip to first unread message

MOEGAMMAT FAIEEZ WHITE

unread,
Jun 5, 2017, 7:33:28 AM6/5/17
to Django users
Hi i am new to Django, can you please guide me as to how i can fetch data from a companies database and insert it into my database. I have been reading about models.py and serializers.py and all tutorials and readings i came accross has online shown be how to display the database data onto the html and how to export data already in the database as json data.


Disclaimer - This e-mail is subject to UWC policies and e-mail disclaimer published on our website at: https://www.uwc.ac.za/Pages/emaildisclaimer.aspx




Jani Tiainen

unread,
Jun 5, 2017, 8:07:08 AM6/5/17
to django...@googlegroups.com

Hi,

First you need to decide how you are going to activate fetch data from remote company database.

Is it a button in user interface, django management commant or maybe timed task?

Secondly you need to decide how to actually fetch that data from remote company database

Through RESTful API? Direct access to database? Some proprietary API?

Finally you need to have models and do necessary data transformations to add data to your local Django database.

But it's not a rocket science. Once you know answers, there are several tools that can help you to achieve your goal easier.


On 05.06.2017 10:48, MOEGAMMAT FAIEEZ WHITE wrote:
Hi i am new to Django, can you please guide me as to how i can fetch data from a companies database and insert it into my database. I have been reading about models.py and serializers.py and all tutorials and readings i came accross has online shown be how to display the database data onto the html and how to export data already in the database as json data.


Disclaimer - This e-mail is subject to UWC policies and e-mail disclaimer published on our website at: https://www.uwc.ac.za/Pages/emaildisclaimer.aspx




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/51eb014a-88f7-48cb-b729-f3c6e32461d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Jani Tiainen
Message has been deleted

MOEGAMMAT FAIEEZ WHITE

unread,
Jun 5, 2017, 8:23:24 AM6/5/17
to Django users

Hi Jani,

i have direct access to the database where the form is stored. I GET the data using the imported requests e,g [r = requests.get(url, auth=HTTPBasicAuth('username', 'password'))]

so the user would have to input his/her user name and password , and the project name for which they want the forms for. i then create a model with only certain key value pairs i want from the database..

my main problem is the models.py and the database insertion of the forms.

also i have a python script which fetches my data, i do not know how to use views.py to do it.

Thank you in advance..
Faieez

Jani Tiainen

unread,
Jun 5, 2017, 8:28:55 AM6/5/17
to django...@googlegroups.com



On 05.06.2017 15:23, MOEGAMMAT FAIEEZ WHITE wrote:

Hi Jani,

i have direct access to the database where the form is stored. I GET the data using the imported requests e,g [r = requests.get(url, auth=HTTPBasicAuth('username', 'password'))]

So your remote database contains some kind of a form that you want to copy to Django database and then represent that form to end user?



so the user would have to input his/her user name and password , and the project name for which they want the forms for. i then create a model with only certain key value pairs i want from the database..

my main problem is the models.py and the database insertion of the forms.


If it's simple key and value pairs doing that isn't much to code, just add two fields that fullfil your requirement.


also i have a python script which fetches my data, i do not know how to use views.py to do it.


Same way as in your script, unless fetch is really slow when you need to think of asynchronous alternatives.


For more options, visit https://groups.google.com/d/optout.

-- 
Jani Tiainen

MOEGAMMAT FAIEEZ WHITE

unread,
Jun 5, 2017, 8:56:54 AM6/5/17
to Django users
I want to get the values and store it. im creating a visualization web application for a data collection application which stores the data directly to the database.

i am doing the application as a honours project, the data collection application is mostly used in under-served communities, and i want to provide a free application that allows the admin user to visualize( in the form of graphs and charts) the data in their forms.

another question, is there an option to create a form that is dynamic? for example different forms will have different fields.

MOEGAMMAT FAIEEZ WHITE

unread,
Jun 5, 2017, 10:12:44 AM6/5/17
to Django users


On Monday, June 5, 2017 at 2:56:54 PM UTC+2, MOEGAMMAT FAIEEZ WHITE wrote:
I want to get the values and store it. im creating a visualization web application for a data collection application which stores the data directly to the database.

i am doing the application as a honours project, the data collection application is mostly used in under-served communities, and i want to provide a free application that allows the admin user to visualize( in the form of graphs and charts) the data in their forms.

another question, is there an option to create a MODELS.PY that is dynamic? for example different forms will have different fields.
Reply all
Reply to author
Forward
0 new messages