Initial version
This commit is contained in:
40
readme.rst
Normal file
40
readme.rst
Normal file
@@ -0,0 +1,40 @@
|
||||
SQL Query Builder based on django ORM
|
||||
=====================================
|
||||
|
||||
What's that?
|
||||
-----------
|
||||
|
||||
Is a library that you can use to build sql queries if your are accustomed to use Django ORM
|
||||
|
||||
|
||||
How to use
|
||||
----------
|
||||
|
||||
There are 3 main objects Q, QuerySet and SQLModel.
|
||||
|
||||
Using it
|
||||
---------------
|
||||
.. code-block:: python
|
||||
|
||||
from sqlbuilder import SQLModel, Queryset, Q
|
||||
|
||||
class Client(SQLModel):
|
||||
table = "clients"
|
||||
|
||||
|
||||
Client.objects.filter(name="Jhon").exclude(lastname="Doe").group_by("family")
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
sql = Queryset("clients").filter(name="Jhon").exclude(lastname="Doe").group_by("family")
|
||||
|
||||
|
||||
sql = Client.objects.filter(Q(name="John") & ~Q(lastname="Doe"))
|
||||
|
||||
sql.group_by("family")
|
||||
|
||||
|
||||
str(sql) will result an string with the sql generated
|
||||
|
||||
|
||||
Reference in New Issue
Block a user