Last active
August 29, 2015 14:14
-
-
Save fereria/d643199e0fc3ee314666 to your computer and use it in GitHub Desktop.
sqlite decorator test
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
## -*- coding: utf-8 -*- | |
""" | |
DecoでConnect | |
""" | |
import sqlite3 | |
import charcode | |
def dbConnect(func): | |
def _dbConnect(*args,**kw): | |
con = sqlite3.connect("./db/jpTest.db") | |
csr = con.cursor() | |
result = func(csr) | |
con.close() | |
return result | |
return _dbConnect | |
@dbConnect | |
def test(csr=None): | |
csr.execute('select name,price from test;') | |
for name,price in csr.fetchall(): | |
print name.encode('utf-8') | |
print price | |
test() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment