Q:

SQLite matching on partial integer

I have the following code:
sic_code = int(input("Filter by SIC code (1-4 digits)? Default is all: ")

# Connect to the database file
conn = sqlite3.connect(db)
c = conn.cursor()

sql = ("SELECT Name "
       "FROM stock_data "
       "WHERE SIC_Code = {sc}".format(sc=sic_code))

# Run SQL query
c.execute(sql)

And here is how the SIC codes look in the database. 

Ideally I'd like to match 7372 regardless of whether the user enters 7, 73, 737 or 7372. I've tried starting with a simple query matching on a 4 digit code but I can not get this to work. The query returns no rows. Without the SIC query, everything works.
Both the SIC column and the user input variable is specified as integer. 
Thanks in advance for any assistance.

A:

None of the above solutions worked for me. Instead, I exported the SQL data back to a pandas data frame and applied the regex there.
Thanks for all your help.
Regards,
Ryan

