LoginSignup
2
2

More than 5 years have passed since last update.

【解決】sqlite3で"0001"をstringのカラムにinsertすると"1"として入る問題

Last updated at Posted at 2014-08-29

解決方法教えてください。

sqlite3
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できない。
2
2
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2