-
Notifications
You must be signed in to change notification settings - Fork 1
Builder Select
Select your data in your database
In the example we will only look at the simplest method of expressions and that is the column in a string. For understanding the deeper possibilities of sql we recommend you to read its documentation.
- Column
- Arithmetic
All listed transfer options are also available in the join column. It is only to note that the table comes first
This is the example and the simplest, here we only work with column, for deeper sql functions it needs the intigrated sqlbuilder functions
.select("name, age, email")All expressions listed above are available here
.select(["name", "age", "email"]).select(["name", Arithmetic(...)])All expressions listed above are available here
.select("name", "age", Arithmetic(...))It is also possible to combine a str or a list with the args
.select("name, age", Arithmetic(...)).select(["name", "age"], Arithmetic(...))conn.table("myTable").select("*")conn.table("myTable").select("name, age, email")-
join_select(join_table: str, expression)- Works like in step "first", it is only added to the existing column, but you have to specify the table of the join from which you want to select the column. -
column_select(expression)- Works like in step "first", it is only added to the existing column -
limit(count: int, offset: int = 0)- Set a maximum select limit, default all, offset default 0 -> Repeat useless
fetchone()fetchall()get_sql()fetchone_json()fetchall_json()
# fetch one
result = connection.table("myTable").select("*").fetchone()
# fetch all
result = connection.table("myTable").select("*").fetchall()
# Select specific column/s
result = connection.table("myTable").select("id").fetchall()
result = connection.table("myTable").select("id, name, age, email").fetchall()
# Select something with where
result = connection.table("myTable").select("name, age, email").where("age", 25).fetchall()
# Multiple where
result = connection.table("myTable").select("name, age, email").where("age", 25).where("name", "Helgo").fetchall()
# Use join (example)
result = connection.table("myTable").select("name").join(InnerJoinBuilder("otherTable").condition("id", "otherId")).join_select("otherTable", "note").fetchall()