This repository was archived by the owner on Oct 29, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Helpful Arithmetic Operators
Miku edited this page Mar 17, 2023
·
1 revision
With the Arithmetic Operators it is possible to use simple mathematics in SQL Builder.
You can find more information about these operators here https://mariadb.com/kb/en/arithmetic-operators/
- Addition
+ - Subtraction
- - Multiplication
* - Division
/ - Modulo
%
Initialise an Arithmetic class
The class accept follow types of variables in each step
- Arithmetic
- ArithmeticColumn
- Integer and Float
from mariadb_sqlbuilder.helpful.arithmetic import Arithmetic
arithmetic = Arithmetic(100)arithmetic.add(100)arithmetic.sub(100)arithmetic.mul(100)arithmetic.div(100)arithmetic.mod(50)The class Arithmetic are repeatable
arithmetic.sub(100).mul(2).add(200)Parenthesis calculation is possible, for this you can simply specify an arithmetic class with the parenthesis values for the variables, this is always repeatable.
arithmetic.mul(Arithmetic(200).add(100))ArithmeticColumn is a class to specify a column for an arithmetic operation instead of a number.
This requires a Table and a Column
ac = ArithmeticColumn(table, column)
# with custom parameters
ac = ArithmeticColumn("user", "money")arithmetic = Arithmetic(ArithmeticColumn("user", "money"))
arithmetic.mul(0.95)