我想检查一下非行的贬低价值,并创造新的价值,因此,需要问一下,一看一看一看是否必须用我的“结构”类会议,或我必须怎样做? 利用像全球这样的会议? i 文件中没有发现。
与此类似:
class MyClass(Base):
__tablename__ = my_class
__table_args__ = (UniqueConstraint( key , key2 ),
{}
)
id = Column(Integer, Sequence( my_class_id ), primary_key=True)
key = Column(String(30), nullable= False) #unique together key2
key2 = Column(String(30), nullable = False)
value = Column(Integer, nullable=False)
def __init__(self, key, key2):
#check if exist key and key2
values = session.query(MyClass.value).filter(MyClass.key == self.key).
filter(MyClass.key2 == self)
if values:
raise IntegrityError
#get biggest value
value = session.query(MyClass.value).filter(MyClass.key = self.key).order_by(asc(MyClass.value)) #I m not shure if i need asc
#no value new key and key2
if not value:
self.key = key
self.key2 = key2
self.value = 000
return
#i used a single table beacuse is easier to understand
#in this example
self.key = key
self.key2 = key
self.value = increment(value.first())
I m 采用LQchemy 6.2和声明
增 编