Created
January 30, 2015 14:03
-
-
Save fereria/e5e1e39e8cfa73851afd to your computer and use it in GitHub Desktop.
sqlite 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 -*- | |
""" | |
SQLITEで日本語を使用するテスト | |
""" | |
import sqlite3 | |
import charcode | |
def createDB(): | |
con = sqlite3.connect("./db/jpTest.db") | |
csr = con.cursor() | |
csr.execute('create table test(id serial,name text,price text)') | |
def test(): | |
con = sqlite3.connect("./db/jpTest.db") | |
csr = con.cursor() | |
csr.execute('insert into test(name,price) values(?,?)',(u"てすと","100")) | |
con.commit() | |
csr.execute('select name,price from test;') | |
for name,price in csr.fetchall(): | |
print name.encode('utf-8') | |
print price | |
con.close() | |
test() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment