Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/359.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Web2py链接表字段类型错误_Python_Mysql_Web2py_Linked Tables - Fatal编程技术网

Python Web2py链接表字段类型错误

Python Web2py链接表字段类型错误,python,mysql,web2py,linked-tables,Python,Mysql,Web2py,Linked Tables,我试图链接web2py中的两个mysql表,它们有一列具有相同的条目(尽管行不同)。我想在网格中显示第一个表,并有一个链接来显示第二个表的相应条目。到目前为止,这就是我所拥有的: in models --> db.py db.define_table('total_ec_numbers', Field('id','integer', label=T('ID')), Field('query_name','string', label=T('Gene ID')),

我试图链接web2py中的两个mysql表,它们有一列具有相同的条目(尽管行不同)。我想在网格中显示第一个表,并有一个链接来显示第二个表的相应条目。到目前为止,这就是我所拥有的:

in models --> db.py

    db.define_table('total_ec_numbers',
    Field('id','integer', label=T('ID')),
    Field('query_name','string', label=T('Gene ID')),
    Field('hit_name','string', label=T('Hit name')),
    Field('hit_accession','string', label=T('Hit accession')),
    Field('ec','string', label=T('EC number')),
    Field('hsp_evalue','string', label=T('E-value')),
    Field('hsp_length','string', label=T('HSP length')),
    Field('hsp_percent','string', label=T('HSP percent')),
    Field('sample','string', label=T('Sample')),
    Field('extra','string', label=T('Extra info')),
    migrate=False, format = '%(query_name)s')

    db.total_ec_numbers._singular = "EC numbers results"
    db.total_ec_numbers._plural = "EC numbers results"


#--------
    db.define_table('total_genes',
    Field('id','integer', label=T('id')),
    Field('gene_id','string', label=T('Contig')),
    Field('gene_name','string', label=T('Gene name')),
    Field('sequence','text', label=T('Sequence')),
    Field('seq_length','integer', label=T('Sequence length')),
    Field('description', 'reference total_ec_numbers', label=T('Gene ID')),
    Field('sample','string', label=T('Sample')),
    Field('extra','string', label=T('Extra info')),
    migrate=False)

    db.total_genes._singular = "All sequences"
    db.total_genes._plural = "All sequences" 


in controllers --> default.py


    important_columns=[db.total_ec_numbers.query_name,db.total_ec_numbers.hit_name,db.total_genes.description]

    form2=SQLFORM.smartgrid(hotzyme_tests.total_ec_numbers, linked_tables=['total_genes'], create=False, fields=important_columns, deletable=False, editable=False, maxtextlength=64, paginate=10)
有了这个,我得到了一个很好的“total_ec_numbers”表格的网格,每个条目旁边都有“all sequences”链接。但是当我点击链接时,我得到以下错误:

ValueError: invalid literal for int() with base 10: '1_start=553_stop=756_strand=+'


The fields that have the identical entries are the db.total_ec_numbers.query_name and the db.total_genes.description and they have string data values. Nevertheless web2py seems to search for integers. Do you know how i can change that? Thank you in advance,

您是否能够更改这些表的结构和内容,或者这是一个与其他系统一起使用的遗留数据库?注意,引用字段用于存储引用记录的整数记录ID,而不是引用记录中字符串字段的副本。另外,您不应该将字段命名为“id”,因为web2py创建了自己的自动递增整数“id”字段作为主键。我可以完全访问数据库是的。我最近才发现存储记录id的引用字段,然后我才意识到它为什么不起作用。我只创建了一个id字段,因为我想使用web2py脚本(用于遗留数据库)为我的所有表自动生成db.py,但我可以更改它。是否有其他方法与字段进行链接?可能是sqlform.grid的“left”属性?