I am trying to assemble the following SQL statement using python's db-api:
SELECT x FROM myTable WHERE x LIKE 'BEGINNING_OF_STRING%';
where BEGINNING_OF_STRING should be a python var to be safely filled in through the DB-API. I tried
beginningOfString = 'abc'
cursor.execute('SELECT x FROM myTable WHERE x LIKE '%s%', beginningOfString)
cursor.execute('SELECT x FROM myTable WHERE x LIKE '%s%%', beginningOfString)
I am out of ideas; what is the correct way to do this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…