我正在尝试使用SQLAlchemy + Python向我的数据库添加一个项目,但不断收到错误.
我的database_setup.py:
class company(Base):
__tablename__ = 'company'
compID = Column(Integer, primary_key = True)
name = Column(String(80), nullable = False)
class item(Base):
__tablename__ = 'items'
itemID = Column(Integer, primary_key = True)
name = Column(String(80), nullable = False)
category = Column(String(250))
description = Column(String(250))
price = Column(String(8))
compID = Column(Integer, ForeignKey('company.compID'))
company = relationship(company)
Run Code Online (Sandbox Code Playgroud)
将sqlalchemy导入终端后,我定义了一个要插入的项目:
JawboneUP3 = item(
itemID="1",
name="Jawbone UP3",
description="The latest UP!",
category="tracker",
price="$174.99",
company="Jawbone"
)
Run Code Online (Sandbox Code Playgroud)
并绘制一个会话来添加和提交:
session.add(JawboneUP3)
session.commit()
Run Code Online (Sandbox Code Playgroud)
当我提交时,我不断收到此错误:
Traceback (most recent call last):
File "<stdin>", line …Run Code Online (Sandbox Code Playgroud) 如何按 kotlin 中的枚举类进行过滤?(刚刚学习)在下面的代码中,文件中前面定义的枚举类是PayStatus{PAID,UNPAID}.
fun nextRentDate(): LocalDate? {
return rentPaymentSchedule.
filter { it.value.paymentStatus is PayStatus.UNPAID}.
minBy { it.value.date.toEpochDay() }?.value?.date
}
Run Code Online (Sandbox Code Playgroud)
我收到错误:Kotlin:
不兼容的类型:PayStatus.UNPAID 和 Enum
我理解我的第一个第二个例子使用传入一个参数的lambda函数.我试图理解为什么它与我的第二个样板示例不同,后者使用双冒号而不是lambda.(仍然是一个kotlin newb试图将我的脑袋缠绕在来自蟒蛇背景的双冒号)
class Service(services: PluginServiceHub) {
init {
services.registerFlowInitiator(Landlord::class.java) { Landlord(it) }
}
}
Run Code Online (Sandbox Code Playgroud)
VS
class Service(services: PluginServiceHub) {
init {
services.registerFlowInitiator(IssuanceRequester::class.java, ::Issuer)
}
}
Run Code Online (Sandbox Code Playgroud)
这究竟::Issuer代表什么?
如何在Pact中注释掉大部分代码?Atom中是否有为此的快捷方式?
我已经尝试过,command+?但是它以HTML格式注释掉了。
但是,这在Pact Web(pact.kadena.io)中确实有效
请尽可能多的表达/定义.
我正在编写一个测试函数,在调用失败后,函数返回:
`this `fails with` "the state is propagated"`
Run Code Online (Sandbox Code Playgroud)
(周围的严重口音失败了^我不知道如何逃避,对不起)