[Solution] When inserting "0001" into the column of string in sqlite3, it is entered as "1".

Please tell me the solution.

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)
#to unko a'1'Enter
#Since the number of digits of a is not fixed, zero padding is not possible.


Recommended Posts

[Solution] When inserting "0001" into the column of string in sqlite3, it is entered as "1".
[Python Data Frame] When the value is empty, fill it with the value of another column.
When a character string of a certain series is in the Key of the dictionary, the character string is converted to the Value of the dictionary.
The solution when an empty object is returned in go's json.Marshal
How to input a character string in Python and output it as it is or in the opposite direction.
When the target is Ubuntu 16.04 in Ansible
In Python, change the behavior of the method depending on how it is called
Differences in the behavior of each LL language when the list index is skipped
Divide the string into the specified number of characters
Find the divisor of the value entered in python
Find the solution of the nth-order equation in python
The background of the characters in the text image is overexposed to make it easier to read.
When a file is placed in the shared folder of Raspberry Pi, the process is executed.
When a local variable with the same name as a global variable is defined in the function
Check if the string is a number in python
Get the variable name of the variable as a character string.
When the selected object in bpy.context.selected_objects is not returned
Store Japanese (multibyte character string) in sqlite3 of python
Check if it is Unix in the scripting language
Implement the solution of Riccati algebraic equations in Python
Embedding in datetime when only the time is known
Check if it is Unix in the scripting language
When you think the update of ManjaroLinux is strange
I tried "Streamlit" which turns the Python code into a web application as it is
The escape symbol of'(Single quote) may be displayed as it is in Python's interactive mode.