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开发者_JAVA技巧")
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.
If you need data-driven presentation in a browser, I (and a lot of other people) would strongly suggest Django http://www.djangoproject.com/.
精彩评论