0

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]
9
  • 1) What sort of table -- a GUI? an HTML table? a PDF report? 2) This has nothing to do with the database, right? Commented Dec 16, 2010 at 16:05
  • at this point i would be happy with either, but my goal is to use html Commented Dec 16, 2010 at 16:06
  • no the database works actually, it connected and it printed everything in the idle, so that was good. Commented Dec 16, 2010 at 16:08
  • @MyHead: yes, that was my point: the database has nothing to do with the question. You are asking how to format some data in an HTML table; it doesn't matter where the data came from! Consider rewriting your question to something like "How to generate HTML tables from Python?" Commented Dec 16, 2010 at 16:10
  • 1
    @MyHead: print HTML.table(resultList) Commented Dec 16, 2010 at 17:50

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

If you need data-driven presentation in a browser, I (and a lot of other people) would strongly suggest Django http://www.djangoproject.com/.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.