本文整理匯總了Python中sqlalchemy.sql.operators.sub方法的典型用法代碼示例。如果您正苦於以下問題:Python operators.sub方法的具體用法?Python operators.sub怎麽用?Python operators.sub使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sqlalchemy.sql.operators
的用法示例。
在下文中一共展示了operators.sub方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _expression_adaptations
# 需要導入模塊: from sqlalchemy.sql import operators [as 別名]
# 或者: from sqlalchemy.sql.operators import sub [as 別名]
def _expression_adaptations(self):
return {
operators.mul: {
Interval: Interval,
Numeric: self.__class__,
Integer: self.__class__,
},
operators.div: {
Numeric: self.__class__,
Integer: self.__class__,
},
operators.truediv: {
Numeric: self.__class__,
Integer: self.__class__,
},
operators.add: {
Numeric: self.__class__,
Integer: self.__class__,
},
operators.sub: {
Numeric: self.__class__,
Integer: self.__class__,
}
}
示例2: _expression_adaptations
# 需要導入模塊: from sqlalchemy.sql import operators [as 別名]
# 或者: from sqlalchemy.sql.operators import sub [as 別名]
def _expression_adaptations(self):
# TODO: need a dictionary object that will
# handle operators generically here, this is incomplete
return {
operators.add: {
Date: Date,
Integer: self.__class__,
Numeric: Numeric,
},
operators.mul: {
Interval: Interval,
Integer: self.__class__,
Numeric: Numeric,
},
operators.div: {Integer: self.__class__, Numeric: Numeric},
operators.truediv: {Integer: self.__class__, Numeric: Numeric},
operators.sub: {Integer: self.__class__, Numeric: Numeric},
}
示例3: test_compare_clauselist_not_associative
# 需要導入模塊: from sqlalchemy.sql import operators [as 別名]
# 或者: from sqlalchemy.sql.operators import sub [as 別名]
def test_compare_clauselist_not_associative(self):
l1 = ClauseList(
table_c.c.x, table_c.c.y, table_d.c.y, operator=operators.sub
)
l2 = ClauseList(
table_d.c.y, table_c.c.x, table_c.c.y, operator=operators.sub
)
is_true(l1.compare(l1))
is_false(l1.compare(l2))
示例4: test_compare_clauselist_not_assoc_different_operator
# 需要導入模塊: from sqlalchemy.sql import operators [as 別名]
# 或者: from sqlalchemy.sql.operators import sub [as 別名]
def test_compare_clauselist_not_assoc_different_operator(self):
l1 = ClauseList(
table_c.c.x, table_c.c.y, table_d.c.y, operator=operators.sub
)
l2 = ClauseList(
table_c.c.x, table_c.c.y, table_d.c.y, operator=operators.div
)
is_false(l1.compare(l2))
示例5: setup_class
# 需要導入模塊: from sqlalchemy.sql import operators [as 別名]
# 或者: from sqlalchemy.sql.operators import sub [as 別名]
def setup_class(cls):
global test_table, meta, MyCustomType, MyTypeDec
class MyCustomType(types.UserDefinedType):
def get_col_spec(self):
return "INT"
def bind_processor(self, dialect):
def process(value):
return value * 10
return process
def result_processor(self, dialect, coltype):
def process(value):
return value / 10
return process
class MyOldCustomType(MyCustomType):
def adapt_operator(self, op):
return {
operators.add: operators.sub,
operators.sub: operators.add,
}.get(op, op)
class MyTypeDec(types.TypeDecorator):
impl = String
def process_bind_param(self, value, dialect):
return "BIND_IN" + str(value)
def process_result_value(self, value, dialect):
return value + "BIND_OUT"
meta = MetaData(testing.db)
test_table = Table(
"test",
meta,
Column("id", Integer, primary_key=True),
Column("data", String(30)),
Column("atimestamp", Date),
Column("avalue", MyCustomType),
Column("bvalue", MyTypeDec(50)),
)
meta.create_all()
with testing.db.connect() as conn:
conn.execute(
test_table.insert(),
{
"id": 1,
"data": "somedata",
"atimestamp": datetime.date(2007, 10, 15),
"avalue": 25,
"bvalue": "foo",
},
)