D
D
devalone2017-10-19 22:10:57
Python
devalone, 2017-10-19 22:10:57

What are the solutions for granting the user access to the database?

I have a python program using Django ORM. which collects proxies, checks and saves them in the database along with various data about them. I want to make an API for accessing the database so that users can send requests like:

"from proxy get url where uptime < {} and !badProxy order_by uptime".format(time.time() - 300)
# uptime is time when proxy starts to work last time

Either like this:
{
  'table': 'proxy',
  'fields': ['url',],
  'filter': AndFilter("!badProxy", "uptime < {}".format(time.time() - 300)),
  'order_by': ['uptime'],
}

Ideally, these queries should be translated into sql (naturally, there should be protection against sql injections) and at the same time it should be possible to set access rights so that it is impossible to look at service tables, do drop databases, etc.
Of course, you can write it yourself, but suddenly there is some ready-made good solution.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2017-10-19
@dimonchik2013

www.django-rest-framework.org

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question