Skip to content

Instantly share code, notes, and snippets.

@utgwkk
Created April 26, 2014 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save utgwkk/11319825 to your computer and use it in GitHub Desktop.
Save utgwkk/11319825 to your computer and use it in GitHub Desktop.
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