I'm executing this query
engine = create_engine(os.getenv("DATABASE_URL"))
db = scoped_session(sessionmaker(bind=engine))
isbn = 03759
a = db.execute("SELECT * FROM books WHERE idnumber LIKE '%:temp%'", {"temp":isbn}).fetchall()
A picture of the books table is referenced: books database
I want to query the rows which have 03759 in their idnumber but python does not allow to add leading zeroes. I tried converting it to string and ran the query but it gave me an error since there was an extra pair of quotes like this:
SELECT * FROM books WHERE idnumber LIKE '%'03759'%'
This is how it got converted by sqlalchemy. Is there any workaround to this so that I can query only those which have 03759 in their idnumber?