1、首先需要在SAE中创建一个python项目,详细参考SAE官方文档
http://sae.sina.com.cn/doc/python/tutorial.html
2、在创建的项目中的MySQL中创建一个表
3、使用如下代码访问
import sae.const
import string
import MySQLdb
_host=sae.const.MYSQL_HOST
_user=sae.const.MYSQL_USER
_passwd=sae.const.MYSQL_PASS
_db=sae.const.MYSQL_DB
_charset= 'utf-8'
_port = string.atoi(sae.const.MYSQL_PORT)
import time,MySQLdb
conn = MySQLdb.connect(host= _host,port= _port,user= _user,passwd= _passwd, db=_db)
cursor = conn.cursor()
result = ""
n = cursor.execute("select * from words")
for row in cursor.fetchall():
for r in row:
result = result + str(r) + " "