Created
August 29, 2014 10:50
-
-
Save puriketu99/0c4416869143be597ffe to your computer and use it in GitHub Desktop.
【解決】sqlite3で"0001"をstringのカラムにinsertすると"1"として入る問題 ref: http://qiita.com/puriketu99/items/135542b08ad295fb8744
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 sqlite3 | |
DATABASE = "unko" | |
def sql4execute(sql,params=[]): | |
db = sqlite3.connect(DATABASE) | |
db.text_factory = str | |
cur = db.execute(sql,params) | |
db.commit() | |
db.close() | |
sql = "insert into unko (a) values ('0001')" | |
sql4execute(sql) | |
#unkoのaに'1'が入る | |
#aの桁数は固定ではないのでzero paddingできない。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment