0

I am trying to search for 133769 substring in our SQL database where the actual no value is 133769-006. I can't seem to find the syntax to use the "IN" line in SQL. My current code returns the revision only when "133769-006" is used.

#connect to cache
no = "133769-006" #want to just search for 133769 without -006
try:
    connection = sqlite3.connect(cache_direc)
    print("Connection to SQLite DB successful")
    cursor = connection.cursor()

    cursor.execute("SELECT revision, cad_item_no FROM Item WHERE no  = (?)", (no,))
    for row in cursor.fetchall():
        if no in row[1]:
            print(row[0])
    
except sqlite3.Error as error:
        print("Failed to read data from sqlite table", error)
finally:
    if connection:
        connection.close()
        #print("The SQLite connection is closed")

If anyone knows how to do this that would be much appreciated

0 Answers0