REMINDER
Python data retrieval
-
Hi team,
Im bit struggling with Cloud backend Api for python. I want to know how can i use pyodbc library in api builder to retrieve data from database and return the response.
Pls guide me? -
Hi,
As we don't provide a python library for this you have to manually make API calls to AppDrag.I suggest you to read the code of our Javascript NPM and reproduce the API calls it make in Python : https://github.com/AppDrag/appdrag-cloudbackend
The code is here:
https://github.com/AppDrag/appdrag-cloudbackend/blob/master/index.jsAnd what might interest you is the sqlSelect and sqlExecuteRawQuery functions
If you have any question while integrate it feel free to ask.
-
@wassim ,
Thanks for your reply.
I still have some doubts with the usage.
In my scenario, i have a form with some text boxes and an file attachment. When user clicks submit, i use ajax calls to send a post request to my python application api. From there, i get the url parameters and files, and save it to my destination folder and database. Then, i will do some sql queries and return some json data back to ajax calls.I want to replicate same functionality here. I can perform ajax calls to the api with required json data and files. But in the backend, how to get those parameters and files, and save the data. Then how to send back some sql query responses as json back to my ajax calls ?
Please help me on this. If possible, some snippets will be helpful.
-
I highly recommend you to follow AppDrag Academy tutorials (https://academy.appdrag.com/), it's based on NodeJs (so javascript) but it's the same logic as Python so if you just need to translate JS to Python must be affordable if you're ok with Python.
-
We don't have a library for Python but from Python you can use our REST API (like from any language)
here is a python example to call cloudbackend to do a SELECT query:
import requests url = "https://api.appdrag.com/CloudBackend.aspx'" params = {"command" : "CloudDBGetDataset","appID" : "YOUR_APPID_HERE", "APIKey":"YOUR_API_KEY_HERE", "query":"SELECT * FROM YOUR_TABLE LIMIT 10"} response = requests.post(url, params) print(response.text)
You can find all API endpoints and required params here in the source of our NPM package for cloudbackend:
https://github.com/AppDrag/appdrag-cloudbackend/blob/master/index.js -