一起来的,这里是我的环境一点点:SQLAlchemy的查询未返回所有的大文本字段
- 使用MSSMS作为我的数据库管理工具。
- 使用Django 1.3
- 使用SQLAlchemy的
我有没有最大长度数据库中的文本字段。其中有890591个字符的文字。
当我使用SQLAlchemy
检索此字段时,它被截断为64512个字符。我已经尝试过与其他几大行,它总是截断为64512.
SELECT @@TEXTSIZE
返回一些荒谬的值,如160万,所以这不是问题。如果我这样做SELECT DATALENGTH(field)
它返回正确的890591.所以它似乎不是数据库,它似乎是SQLAlchemy
。或者也许它可能是一些Python限制。
任何想法?我似乎在我的智慧结束。
编辑:下面是一些被要求更多的信息:
OS:Debian的5.0.9
的SQLAlchemy:0.7.3
SQL:MS SQL Server 2008中
DB连接: MSSQL + pymssql://用户名:密码@服务器/ DBNAME
pymssql版本:1.0.2
模型问题:
class RACReport(Base):
__tablename__ = 'RACReport'
id = Column(properUUID(), primary_key=True, nullable=False, default=genuuid4, server_default=text('NEWID()'))
client_id = Column(properUUID(), ForeignKey(Client.id), nullable=False)
rawdata = Column(Text(), nullable=True)
rawtime = Column(DateTime(), nullable=True, default=datetime.datetime.now())
processeddata = Column(Text(), nullable=True)
processedtime = Column(DateTime(), nullable=True)
reportstartdate = Column(DateTime(), nullable=False)
reportenddata = Column(DateTime(), nullable=False)
numberofdocs = Column(Integer(), nullable=True)
RACReport.__table__.schema='rac'
class properUUID(st.TypeDecorator):
impl = mssql.MSUniqueIdentifier
def process_result_value(self, value, dialect):
if value:
return str(uuid.UUID(bytes_le=value))
def genuuid4():
return str(uuid.uuid4())
RAWDATA和过程数据是他是有这个问题的两个领域。
这是一个测试查询和回声:
rac.session.query(rac.RACReport).filter(rac.RACReport.id=='8fb76cb7-d752-45af-a20a-3b85d5e7b8a6').all()
2011-11-17 09:39:46,890 INFO sqlalchemy.engine.base.Engine SELECT [RACReport_1].id AS [rac_RACReport_id], [RACReport_1].client_id AS [rac_RACReport_client_id], [RACReport_1].rawdata AS [rac_RACReport_rawdata], [RACReport_1].rawtime AS [rac_RACReport_rawtime], [RACReport_1].processeddata AS [rac_RACReport_processeddata], [RACReport_1].processedtime AS [rac_RACReport_processedtime], [RACReport_1].reportstartdate AS [rac_RACReport_reportstartdate], [RACReport_1].reportenddate AS [rac_RACReport_reportenddate] FROM rac.[RACReport] AS [RACReport_1] WHERE [RACReport_1].id = %(id_1)s 2011-11-17 09:39:46,890 INFO sqlalchemy.engine.base.Engine {'id_1': '8fb76cb7-d752-45af-a20a-3b85d5e7b8a6'}
有趣的是,价值是相同的2^16 - 2^10。 –
@BrianCain我也这么认为... – MatthewKremer
你可以用'pdb'或'pudb'单步进入相关的'SQLAlchemy'代码吗? –