neuralib.sqlp.stat.SqlUpdateStat
- class neuralib.sqlp.stat.SqlUpdateStat[source]
Bases:
SqlStat[T],SqlWhereStat,SqlLimitStat,SqlReturnStat,Generic[T]- __init__(table)
- Parameters:
table (type[T] | None)
- add(stat)
Add SQL token.
- Return type:
Self
- build()
build a SQL statement.
- Return type:
tuple[str, list]
- drop()
- limit(*args)
LIMIT: https://www.sqlite.org/lang_select.html#limitoffset>>> select_from(A).limit(10).build() SELECT * FROM A LIMIT 10 >>> select_from(A).limit(10, 10).build() SELECT * FROM A LIMIT 10 OFFSET 10
NOTE
LIMIT on UPDATE/DELETE need compile flag
SQLITE_ENABLE_UPDATE_DELETE_LIMIT.>>> assert Connection().sqlite_compileoption_used('SQLITE_ENABLE_UPDATE_DELETE_LIMIT')
- Parameters:
args (int)
- Return type:
Self
- order_by(*by)
ORDER BY: https://www.sqlite.org/lang_select.html#orderby>>> select_from(A).order_by(A.a).build() SELECT * FROM A ORDER BY A.
possible ordering
>>> select_from(A).order_by( ... asc(A.a), desc(A.b), nulls_first(A.c), asc(A.d).nulls_last(), ... ) SELECT * FROM A ORDER BY A.a ASC, A.b DESC, A.c NULLS FIRST, A.d ASC NULLS LAST
NOTE
ORDER BY on UPDATE/DELETE need compile flag
SQLITE_ENABLE_UPDATE_DELETE_LIMIT.>>> assert Connection().sqlite_compileoption_used('SQLITE_ENABLE_UPDATE_DELETE_LIMIT')
- Parameters:
by (int | str | SqlExpr | Any)
- Return type:
Self
- returning(*expr)
- Parameters:
expr (str | Any)
- Return type:
Self
- submit()
build the SQL statement and execute.
- Returns:
a cursor
- Raises:
RuntimeError – current statement does not bind with a connection.
- Return type:
Cursor[T]
- where(*expr)
WHEREclause: https://www.sqlite.org/lang_select.html#whereclause>>> select_from(A).where( ... A.a == 1, A.b == 2 ... ).build() SELECT * FROM A WHERE (A.a = 1) AND (A.b = 2)
- Parameters:
expr (bool | SqlCompareOper | SqlExpr | None)
- Returns:
- Return type:
Self
- from_(query)[source]
- Parameters:
query (SqlStat | SqlAlias[SqlSubQuery])
- Return type:
Self