diff --git a/book/cooltools/Chapter.ipynb b/book/cooltools/Chapter.ipynb index feec4ec..ffea5a4 100644 --- a/book/cooltools/Chapter.ipynb +++ b/book/cooltools/Chapter.ipynb @@ -1665,6 +1665,45 @@ " }\n", " )" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## SQL Query Builder in Python" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You can build SQL queries in Python with pypika.\n", + "\n", + "pypika provides a simple interface to build SQL queries with an easy syntax.\n", + "\n", + "It supports nearly every SQL command." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from pypika import Tables, Query\n", + "\n", + "history, customers = Tables('history', 'customers')\n", + "q = Query \\\n", + " .from_(history) \\\n", + " .join(customers) \\\n", + " .on(history.customer_id == customers.id) \\\n", + " .select(history.star) \\\n", + " .where(customers.id == 5)\n", + " \n", + "q.get_sql()\n", + "# SELECT \"history\".* FROM \"history\" JOIN \"customers\" \n", + "# ON \"history\".\"customer_id\"=\"customers\".\"id\" WHERE \"customers\".\"id\"=5" + ] } ], "metadata": { diff --git a/book/pythontricks/Chapter.ipynb b/book/pythontricks/Chapter.ipynb index 0e64bb5..3b1ef79 100644 --- a/book/pythontricks/Chapter.ipynb +++ b/book/pythontricks/Chapter.ipynb @@ -961,7 +961,15 @@ { "cell_type": "markdown", "metadata": {}, - "source": [] + "source": [ + "One cool feature in Python 3.12:\n", + "\n", + "The support for Type Variables.\n", + "\n", + "You can use them to parametrize generic classes and functions.\n", + "\n", + "See below for a small example where our generic class is parametrized by T which we indicate with [T]." + ] }, { "cell_type": "code",