I had trouble with selecting TEXT data type padded with zeros in front.
Found out there's something wrong with my DB.
My multiple tries and all of answers by peers should all should work.
Thanks @snakecharmerb and @forpas for pointing out for possible flaw in DB.
For example, code column includes
000001, 000010, 000300 ...
There are also a multiple of Data with same code.
code date
000030 20210101
000030 20210102
000030 20210103
000030 20210104
000030 20210105
...
I need to loop through a list so I tried multiple ways of using f-string, but it did not work.
con = sqlite3.connect("DIRECTORY")
cur = con.cursor()
code = '000030' // does not work
code = 000030 // forbidden by python 3.7
query = cur.execute(f"SELECT * From TABLE where code is {code}") // should work
query = cur.execute(f"SELECT * From TABLE where code is '{code}'") // should work
query = cur.execute(f'SELECT * From TABLE where code is "{code}"') // should work
query = cur.execute('SELECT * From TABLE where code = ?',('000030',)) // should work
query = cur.execute("SELECT * From TABLE where code is 000030") // works but cannot loop through a list
Also tried replacing 'is' with '=', '=='. All should work.