Skip to content

Instantly share code, notes, and snippets.

@fereria
Created January 30, 2015 14:03
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 fereria/e5e1e39e8cfa73851afd to your computer and use it in GitHub Desktop.
Save fereria/e5e1e39e8cfa73851afd to your computer and use it in GitHub Desktop.
sqlite test
## -*- 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