插入数据库时​​出现语法错误[Google app engine]

时间:2013-03-02 17:01:50

标签: python database google-app-engine syntax

尝试插入数据存储区时出现语法错误,完全相同的代码行在另一个项目中工作

    B = db_Person(nafn='Alex')

以下是代码的其余部分:

http://pastebin.com/bW37aUuT

1 个答案:

答案 0 :(得分:1)

def post(self):
    q = db.Query(db_Person)

    message = "Innsetning tokst"

    in_kennitala = int(self.request.get('p_kennitala'))
    in_nafn = self.request.get('p_nafn')
    in_heimili = self.request.get('p_heimili')
    in_postnumer = self.request.get('p_postnumer')
    in_stadur = self.request.get('p_stadur')
    in_land = self.request.get('p_land')
    in_simi = int(self.request.get('p_simi'))
    in_gsm = int(self.request.get('p_gsm')    # <- missing right parenthesis

    B = db_Person(nafn='Alex')                # <- parser gets confused here
    B.put()

    template_values = {
            'message': message
    }

    template = jinja_environment.get_template('breyta.html')
    self.response.out.write(template.render(template_values))

这是固定代码:

def post(self):
    q = db.Query(db_Person)

    message = "Innsetning tokst"

    in_kennitala = int(self.request.get('p_kennitala'))
    in_nafn = self.request.get('p_nafn')
    in_heimili = self.request.get('p_heimili')
    in_postnumer = self.request.get('p_postnumer')
    in_stadur = self.request.get('p_stadur')
    in_land = self.request.get('p_land')
    in_simi = int(self.request.get('p_simi'))
    in_gsm = int(self.request.get('p_gsm'))

    B = db_Person(nafn='Alex')
    B.put()

    template_values = {
            'message': message
    }

    template = jinja_environment.get_template('breyta.html')
    self.response.out.write(template.render(template_values))