简体   繁体   中英

Using pyodbc, and html.py to generate a table

I just started to play around with python, and i really like it. I am able to connect to my database using pydobc and print the results. However, i need help taking the next step to placing the information in a table in a 'form'

import pyodbc
connection = pyodbc.connect(MY STRING)
cur = connection.cursor() 
cur.execute("select top(10) May07Control.seq, May07Control.member from dbo.May07Control")
for row in cur:
    print "member: %s"% row.member
    print "seq: %s"% row.seq

##OR the one-line way

cur.execute("select May07Control.seq, May07Control.member from dbo.May07Control")
resultList = [(row.member, row.seq) for row in cur]

So if you're running Python through IDLE and you're aiming at a browser view/interface. The next step is to get a development server running on your local machine. All the template engines come with cookbook instructions on how to do this. Bottle is a very simple example.

I personally use the development servers that come with Google App Engine, and PyDev in Eclipse, and you could potentially use the included Python server .

如果你需要在浏览器中进行数据驱动的演示,我(以及很多其他人)会强烈建议使用Django http://www.djangoproject.com/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM