Created
April 26, 2014 13:16
-
-
Save utgwkk/11319825 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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