"reprinted" with Karrigell for rapid web development (connection to MySQL database)

Source: Internet
Author: User
Tags fast web

Http://blog.chinaunix.net/uid-8581780-id-347984.html

For a fast web development task, I usually choose Karrigell as a tool. Karrigell is intuitive and makes you feel that it's so convenient to develop a Web application. She's a bit like PHP or JSP, but it's definitely not an MVC architecture. If you use Python,karrigell is the PHP you have in hand. You can embed HTML in Python, or you can embed Python in HTML. Very convenient.
In addition, a bit to note, if you want to use your Python as a form of action, then this Python do not use if __name__ = = "__main__", you can directly write code, the above syntax is not supported. Using Karrigell you will feel that the difference between doing the Web programming and the console programming is not great, and for some small, fast-to-frame tasks that are very suitable.
A way to access MySQL and see what's different.

1 ImportMysqldb,pdb,sys2 Try:3conn = MySQLdb.connect (host='192.168.x.x', user='XXX', passwd='XXX', db='XXX')4 exceptexception,e:5         PrintStr (e)6 sys.exit ()7Cur =conn.cursor ()8sql = Unicode ('INSERT INTO Msg_to_send values tablename (NULL, '%s ', '%s ', now ());'% (query["name"],query["School"]),'latin1')9 #Print SQLTen Try: OneCur.execute ("SET NAMES ' GBK '") A cur.execute (SQL) - Conn.commit () - exceptexception,e: the         PrintStr (e) - sys.exit () - cur.close () - conn.close () + Print 'ok!'

"reprinted" with Karrigell for rapid web development (connection to MySQL database)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.