- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
如果我将 CapacityMin
类和单元测试类放在同一个 .py 文件中,一切都很好。但是在我将 CapacityMin
类移动到一个单独的文件并运行单元测试后,我得到了这个错误:
需要 SQL 表达式、列或映射实体
详情:
InvalidRequestError: SQL expression, column, or mapped entity expected - got '<module 'Entities.CapacityMin' from 'D:\trunk\AppService\Common\Entities\CapacityMin.pyc'>'
但这并不好。
CapacityMin.py:
import sqlalchemy
from sqlalchemy import *
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class CapacityMin(Base):
'''
table definition:
ID INT NOT NULL auto_increment,
Server VARCHAR (20) NULL,
FeedID VARCHAR (10) NULL,
`DateTime` DATETIME NULL,
PeakRate INT NULL,
BytesRecv INT NULL,
MsgNoSent INT NULL,
PRIMARY KEY (ID)
'''
__tablename__ = 'capacitymin'
ID = Column(Integer, primary_key=True)
Server = Column(String)
FeedID = Column(String)
DateTime = Column(sqlalchemy.DateTime)
PeakRate = Column(Integer)
BytesRecv = Column(Integer)
MsgNoSent = Column(Integer)
def __init__(self, server, feedId, dataTime, peakRate, byteRecv, msgNoSent):
self.Server = server
self.FeedID = feedId
self.DateTime = dataTime
self.PeakRate = peakRate
self.BytesRecv = byteRecv
self.MsgNoSent = msgNoSent
def __repr__(self):
return "<CapacityMin('%s','%s','%s','%s','%s','%s')>" % (self.Server, self.FeedID ,
self.DateTime ,self.PeakRate,
self.BytesRecv, self.MsgNoSent)
if __name__ == '__main__':
pass
最佳答案
您使用的是模块,而不是模块中的类。
我怀疑你是这样使用它的:
from Entities import CapacityMin
当你打算使用时:
from Entities.CapacityMin import CapacityMin
这种混淆是 Python styleguide (PEP 8) 的原因之一。建议为您的模块使用小写名称;您的导入将是:
from entities.capacitymin import CapacityMin
而且您的错误会更容易被发现。
关于 python sqlAlchemy : got InvalidRequestError after change class location,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11898551/
我正在尝试找出这两个部分之间的区别,这似乎与 question 重复,但那里给出的答案并没有解释很多,所以我想要一个更详细和简洁的解释。 最佳答案 拆分是出于安全原因。默认情况下(过去仅在 -Wl,-
ELF 格式的 .got 和 .got.plt 部分有什么区别? 最佳答案 我之前的评论是对的: I think .got is for relocations regarding global 'v
我知道在典型的 ELF 二进制文件中,函数是通过过程链接表 (PLT) 调用的。函数的 PLT 条目通常包含到全局偏移表 (GOT) 条目的跳转。该条目将首先引用一些代码以将实际函数地址加载到 GOT
我知道在典型的 ELF 二进制文件中,函数是通过过程链接表 (PLT) 调用的。函数的 PLT 条目通常包含到全局偏移表 (GOT) 条目的跳转。该条目将首先引用一些代码以将实际函数地址加载到 GOT
我对 SICP 1.37 的迭代解决方案是 (define (con-frac n d k) (define (iter i result) (if (= 1 i) res
我正在尝试开始部署,但收到此错误 error: error validating "httpd-basic-deployment.yaml": error validating data: Valid
获取错误 ORA-00932: inconsistent datatypes: expected CHAR got NUMBER 00932. 00000 - "inconsistent dataty
我在没有全局偏移表的情况下编译多个 PIC 文件时遇到问题。 使用以下参数编译第一个文件 onefile.c 时,程序集不包含对 GOT 的引用: arm-none-eabi-gcc.exe firs
Your smiling at me is my daily dose of magic. 你嫣然的微笑是我每日享受到的魅力。 you hold a piece of me no matte
我是 Twilio 的新手。我正在尝试使用本教程将 SMS 转发到电子邮件地址: https://www.twilio.com/blog/2017/07/forward-incoming-sms-me
谁能帮我在 GWT 上创建离线 map ,我听说过 OpenLayers,但我没有找到任何源代码,你对此有什么想法吗?谢谢。 最佳答案 您将需要GWT-Openlayers Wrapper对于 Ope
我正在处理一些在编译为 PIC(位置无关代码)时速度变慢 70-80% 的代码,并且正在寻找缓解问题的方法。问题的很大一部分是 gcc 坚持在每个函数中插入以下内容: call __i686.get_
我编写了一个自定义 hamcrest 匹配器,用于检查列表中的文件是否已被复制。该列表可能很长(1000 个以上文件),因此如果缺少一个文件,我不希望匹配器打印出整个列表。 我可以为丢失的文件进行自定
我的意思是在模块中定义的非静态全局变量,而不是在外部。 为什么一定要通过GOT引用呢?为什么不使用相对地址?(因为.data 段中的全局变量和.text 段中的引用之间的距离是一个常量,它也是位置无关
当我在阅读时 http://eli.thegreenplace.net/2011/11/03/position-independent-code-pic-in-shared-libraries/#id
某些特定于平台的功能(例如 SSE 或 AVX)的可用性可以在运行时确定,如果不想为不同的功能编译和发布不同的对象,这将非常有用。 例如,以下代码允许我检查 AVX 并使用 gcc 进行编译,它提供了
我如何检查互联网连接是否成功(Wifi/3G/其他) 如果用户没有 Wifi 连接,我已经向用户显示错误,但我如何才能确保用户确实获得了 3G 连接如果他们希望在没有 Wifi 连接的情况下连接使用应
这是示例程序集文件,test.s .global main main: mov __progname@GOT, %eax // failed to compile mov __
mysqldump:得到错误:1449:使用锁表时指定为定义者的用户('root'@'192.200.1.16')不存在 请给出上述错误的解决方案。 最佳答案 最好使用第一个mysqldump和--s
前言:本篇为笔者学习极客时间《深入浅出计算机组成》过程中的部分疑问和解疑记录,因为这一块问题笔者学习过程中搜索所得答案较少,故留此博客。 1. 编译、链接和加载 我们知道,“C 语言代码 - 汇编代码
我是一名优秀的程序员,十分优秀!