Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.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
Html 如何将sqlite db值传递给控制器_Html_Sqlite_Web2py - Fatal编程技术网

Html 如何将sqlite db值传递给控制器

Html 如何将sqlite db值传递给控制器,html,sqlite,web2py,Html,Sqlite,Web2py,sqlite的新手,web2py。我正在尝试将sqlite db内容复制到另一个函数的控制器。 我的代码如下: db.py 默认值: @auth.requires_login() def index(): chats.index(db) body = db.chat.me_body() rows = db(db.chat.me_body).select()#(orderby=~db.chat.me_body.created_on) form

sqlite的新手,web2py。我正在尝试将sqlite db内容复制到另一个函数的控制器。 我的代码如下: db.py

默认值:

@auth.requires_login()
def index():
    chats.index(db)    
    body = db.chat.me_body()    
    rows = db(db.chat.me_body).select()#(orderby=~db.chat.me_body.created_on)    
    form1 = [body]    
    form5 = form1#.split()    
    name3 = ' '.join(form5)
我不想检索发布到db的字符串

    chat.id chat.me_from    chat.me_body    chat.me_html
1                      
2       maurice         hi              <div class="m...
3       maurice         whats up        <div class="m...
4       maurice         where are you.  <div class="m...
5       maurice         3i5ejp[eoityjdt <div class="m...
6       maurice         how are you d...<div class="m...
7       maurice         britam          <div class="m...
如果我使用:

`body = db.chat.me_body
错误是:

TypeError: 'Field' object is not callable
TypeError: sequence item 0: expected string, Field found
name3 = ' '.join(form5)
TypeError: sequence item 0: expected string, Rows found
如果我使用行:

rows = db(db.chat.me_body).select()

错误是:

TypeError: 'Field' object is not callable
TypeError: sequence item 0: expected string, Field found
name3 = ' '.join(form5)
TypeError: sequence item 0: expected string, Rows found

我将感谢您的帮助

执行查询以从数据库中获取记录的正确方法是:

rows = db(db.chat).select(db.chat.me_body, db.chat.created_on,
                          orderby=~db.chat.created_on)
注意,
db(db.chat)
是查询
db(db.chat.id!=None)
(即选择表中的所有记录)的简写形式

然后,要将
me\u body
字段值提取到列表中,可以使用列表理解:

me_body_values = [r.me_body for r in rows]
最后,您可以将这些值连接在一起:

name3 = ' '.join(me_body_values)

我强烈建议您花一些时间阅读web2py文档(可能还会复习Python),因为您所展示的代码中存在许多错误和误解。