Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pymssql
- import itertools
- connection = pymssql.connect(server="192.168.1.1", user="Me", password="password", port=1234, database="Blue")
- cur = connection.cursor()
- cur.execute('SELECT * FROM testtable')
- varone = cur.fetchall()
- connection.close()
- hope = list(itertools.chain(*varone))
- def print_table(data, row_length):
- counter = 0
- for element in data:
- if counter % row_length == 0:
- print ('<tr>')
- print ('<td align="center">%s</td>' % element)
- counter += 1
- if counter % row_length == 0:
- print ('</tr>')
- if counter % row_length != 0:
- for i in range(0, row_length - counter % row_length):
- print ('<td align="center"> </td>')
- print ('</tr>')
- print ('Content-type:text/htmlrnrn')
- print ('<!DOCTYPE HTML>')
- print ('<html lang="en">')
- print ('<meta charset="UTF-8">')
- print ('<head>')
- print ('<title>Table Example</title>')
- print ('<style>table {width: 40%} table, th, td {border: 1px solid black} </style>')
- print ('</head>')
- print ('<body>')
- print ('<table>')
- print ('<tr>')
- print ('<th>First Name</th>')
- print ('<th>Last Name</th>')
- print ('<th>Date</th>')
- print ('<th>Random Number</th>')
- print ('</tr>')
- print_table(hope, 4)
- print ('</table>')
- print ('</html>')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement