Re: Get data from an external api into my database.

2018-03-20 Thread 'Tom Evans' via Django users
On Tue, Mar 20, 2018 at 10:23 AM, Mukesh Jha  wrote:
> I want to access a api from http://open-platform.theguardian.com/ or
> https://newsapi.org/ and load it into my sqlite database. The data in these
> site is in json format and I want them to get converted into my database
> model format and store in it and later on use them as when queried. I am
> clueless as I am quite new in this development system. Please help if
> possible.
>

Adjust for your needs:

  data = requests.get(url).json()
  for datum in data:
  MyModel.objects.save(**datum)

Cheers

Tom

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/CAFHbX1%2BHs0DHHZtpR8L2asSAtNLdw_NaJF-ST9%2BRsTwQ021-fA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Get data from an external api into my database.

2018-03-20 Thread Jani Tiainen
Hi.

Requests library will be your friend.

ti 20. maaliskuuta 2018 klo 14.05 Mukesh Jha 
kirjoitti:

> I want to access a api from http://open-platform.theguardian.com/ or
> https://newsapi.org/ and load it into my sqlite database. The data in
> these site is in json format and I want them to get converted into my
> database model format and store in it and later on use them as when
> queried. I am clueless as I am quite new in this development system. Please
> help if possible.
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@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/6ca83919-9b2a-42c3-bfde-0c66faef4910%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/CAHn91oeqGFG%2Bti-FdO2npyHBp5Vf-5ZfDVx7OaK7jBt9T%2BAJSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Get data from an external api into my database.

2018-03-20 Thread Mukesh Jha
I want to access a api from http://open-platform.theguardian.com/ or 
https://newsapi.org/ and load it into my sqlite database. The data in these 
site is in json format and I want them to get converted into my database 
model format and store in it and later on use them as when queried. I am 
clueless as I am quite new in this development system. Please help if 
possible.

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/6ca83919-9b2a-42c3-bfde-0c66faef4910%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.