在新浪sae下部署python程序数据库配置问题 an integer is required

来源:互联网 发布:rpg游戏推荐 知乎 编辑:程序博客网 时间:2024/06/06 08:28

在新浪sae下部署python web应用和本地其实没有多大却别,也就是文件系统限制比较大。

新浪sae有提供mysql数据库。在使用python配置db的时候,出现了an integer is required错误。

新浪sae提供的mysql数据库有他定义好的链接信息,存在sae.const属性中,

import sae.const导入模块引用属性。


db = web.database(dbn='mysql',                  db=sae.const.MYSQL_DB,                  user=sae.const.MYSQL_USER,                  pw=sae.const.MYSQL_PASS,                  host=sae.const.MYSQL_HOST,                  port=int(sae.const.MYSQL_PORT)                  )

sae.const.MYSQL_DB #数据库名称

sae.const.MYSQL_USER #用户名

sae.const.MYSQL_PASS #密码

sae.const.MYSQL_HOST #域名

sae.const.MYSQL_PORT #端口

出现an integer is required错误的原因就是这个sae.const.MYSQL_PORT是一个字符串,只要使用int转换就可以使用。这个问题一开始还不知道,因为使用过很多提供数据库信息的模块,端口都是int属性,这个有点异同。

原创粉丝点击