def addrss(): if session.has_key('username'): username = session['username'] else: return 'no login' db = MySQLDatabase(app.config['DATABASE'], host = app.config['DATABASEHOST'], user = app.config['USERNAME'], passwd = app.config['PASSWORD']) cur = db.get_cursor() cur.execute('select count(id) from rsslist') count = cur.fetchall() count = int(count[0][0]) cmd = 'insert into rsslist (id, name, xmlurl, htmlurl, user) values(' + str(count) + ',' + '"' + request.form['name'] + '"' + ',' + '"'+request.form['rssxml'] +'"'+ ',' + '"'+request.form['rsshtml'] +'"'+ ',' + '"'+username +'"'+ ')' cur.execute(cmd) #cur.commit() db.commit() setcache(username) return 'add finish'
import score if __name__ == '__main__': Config.load('../config/server.json') database = MySQLDatabase(Config.mysql_db, autocommit=False, **{'threadlocals': True, 'host': Config.mysql_host, 'password': Config.mysql_pwd, 'port': Config.mysql_port, 'user': Config.mysql_user}) # Connect to our database. database.begin() # Create the tables. database.create_tables([ # grade.Grade, major.Major, student_info.StudentInfo, student_behavior.StudentBehavior, student_punish.StudentPunish, student_relative.StudentRelative, student_resume.StudentResume, student_reward.StudentReward, course.Course, term.Term, score.Score ], safe=True) database.commit()