Hello,
 Please I need advice on how I can go on with this.
Thanks

On Sat, Mar 23, 2019 at 8:26 PM carl collins <carlcollinswa...@gmail.com>
wrote:

> Hello guys,
> I'm Carl Collins from Cameroon. I'm working on this Django Project and I
> got stuck . Need help.The first thing I   would love to ask is about
> performing SQL queries in Django use Django ORM. Presume I have something
> like this:
>
> connection = sqlite.connect('data.db')
> cursor = connection.cursor()
>
> query = "SELECT * FROM items"
> result = cursor.execute(query)
>
> properties = []
> for row in result:
> items.append({})
>
> connection.close()
> print(json.dumps({'properties': properties})
>
>
>
> I would love Django to run this automatically i.e fetch some field from
> the database each time a button is clicked  and do a post request to an API
> using the json returned as the body of the request
>
> NB: The data in the database is populated using a django form and I would
> love to use the same data to do a post request to an api. The API requires
> that the post body be in json format like
>
> {
> "currency": "",
> "customerName": "",
> "description": "",
> "email": "",
> "expiryDate": "",
> "id": {
> "uuid": "",
> "version": ""
> },
> "items": [
> {
> "itemId": "",
> "particulars": "",
> "quantity": x,
> "subTotal": y,
> "unitCost": z
> },
> {
> "itemId": " ",
> "particulars": " ",
> "quantity": j,
> "subTotal": k,
> "unitCost": l
> }
> ],
> "langKey": "en",
> "merchantReference": " ",
> "orderDate": " ",
> "phoneNumber": " ",
> "receiptUrl": " ",
> "totalAmount": n
> }
>
>
> Thanks in advance
> Cheers
> Carl
>

-- 
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/CAEPm0by6ejQ-8t%3D1obj0nLW-8YXTRj8JfaYksz08i7qfr-H2HA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to