【轉載】用karrigell進行快速web開發(串連mysql資料庫)

來源:互聯網
上載者:User

標籤:

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

對於一件快速的web開發工作單位,我一般會選擇karrigell來作為工具。karrigell很直觀,而且讓你感覺到開發一個web應用真得如此方便。她有點像php或jsp,但是卻絕不是MVC構架。如果你用python,karrigell就是你手頭的php了。你可以在python中嵌入html,也可以在html中嵌入python.非常方便。
另外,有點要注意,你如果要把你的python作為一個表單的action,那麼這個python中不要用if __name__ == "__main__",可以直接寫代碼即可,上述文法並不支援。使用karrigell你會覺得在做web編程和進行控制台編程差別不是很大,對於一些小型快速的不要考慮架構的任務是非常適合的。
放一段訪問mysql的方法,看看有什麼不同吧。

 1 import MySQLdb,pdb,sys 2 try: 3         conn = MySQLdb.connect(host=‘192.168.x.x‘,user=‘xxx‘,passwd=‘xxx‘,db=‘xxx‘) 4 except Exception,e: 5         print str(e) 6         sys.exit() 7 cur = conn.cursor() 8 sql = unicode(‘insert into msg_to_send values tablename(NULL,"%s","%s",now());‘ % (QUERY["name"],QUERY["school"]),‘latin1‘) 9 #print sql10 try:11         cur.execute("SET NAMES ‘gbk‘")12         cur.execute(sql)13         conn.commit()14 except Exception,e:15         print str(e)16         sys.exit()17 cur.close()18 conn.close()19 print ‘OK!‘

 

【轉載】用karrigell進行快速web開發(串連mysql資料庫)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.