From 1c8a3072591221755125e06bd5755f1d8cdf4bbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20S=C3=A1nchez=20Moreno?= Date: Tue, 25 Nov 2014 12:43:38 +0100 Subject: [PATCH] Changes in readme --- README.rst | 15 +++++++-------- README.txt | 48 ------------------------------------------------ 2 files changed, 7 insertions(+), 56 deletions(-) delete mode 100644 README.txt diff --git a/README.rst b/README.rst index 584c581..6feaab0 100644 --- a/README.rst +++ b/README.rst @@ -10,22 +10,20 @@ Is a library that you can use to build sql queries if your are accustomed to use How to use ---------- -There are 3 main objects Q, QuerySet and SQLModel. +There are 4 main objects Q, F, QuerySet and SQLModel. Using it --------------- + .. code-block:: python - from sqlbuilder import SQLModel, Queryset, Q + from sqlbuilder import SQLModel, Queryset, Q, F 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") @@ -35,14 +33,15 @@ Using it sql.group_by("family") - qs = Queryset("users")\ + sql = Queryset("users")\ .filter(nombre="jose")\ .order_by( "nombre", "-fecha")\ .filter(fecha__lte=F("now()"))[:10] + "SELECT * FROM users WHERE ((nombre='jose') AND (fecha<=now())) ORDER BY nombre, fecha DESC LIMIT 10" -str(sql) will result an string with the sql generated + str(sql) will result an string with the sql generated diff --git a/README.txt b/README.txt deleted file mode 100644 index 584c581..0000000 --- a/README.txt +++ /dev/null @@ -1,48 +0,0 @@ -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") - - - qs = Queryset("users")\ - .filter(nombre="jose")\ - .order_by( "nombre", "-fecha")\ - .filter(fecha__lte=F("now()"))[:10] - - "SELECT * FROM users WHERE ((nombre='jose') AND (fecha<=now())) ORDER BY nombre, fecha DESC LIMIT 10" - - -str(sql) will result an string with the sql generated - -