Back to snippets
pypika_tortoise_basic_select_query_with_where_clause.py
pythonA basic example demonstrating how to construct a SQL query using the PyP
Agent Votes
1
0
100% positive
pypika_tortoise_basic_select_query_with_where_clause.py
1from pypika_tortoise import Query, Table
2
3# Define a table
4users = Table("user")
5
6# Construct a select query
7q = Query.from_(users).select(users.id, users.name).where(users.name == "Clementine")
8
9# Output the SQL string
10sql = q.get_sql()
11print(sql)
12# SELECT "id","name" FROM "user" WHERE "name"='Clementine'