Skip to content

Instantly share code, notes, and snippets.

@utgwkk
Created Apr 26, 2014
Embed
What would you like to do?
import tempfile
import sqlite3
import webbrowser
if __name__ == '__main__':
conn = sqlite3.connect('hoge.db')
c = conn.cursor()
tmp = tempfile.mkstemp(prefix='pythontemp_', suffix='.htm')
f = open(tmp[1], 'wt')
b = ''
for data in c.execute('SELECT * FROM Table ORDER BY date'):
b += '<tr>'
for c in data: b += '<td>%s</td>'%c
b += '</tr>\n'
html = '''<!DOCTYPE html>
<html>
<body>
<table border="1px">
%s
</table>
</body>
</html>'''%b
f.write(html)
f.close()
webbrowser.open('file:///'+tmp[1])
conn.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment