0

I'm querying to see if a particular URL exists in my table:

query = 'SELECT EXISTS(SELECT * FROM table WHERE LINK = %s)'
c.execute(query, [link])
result = c.fetchall()[0][0]

If I set link equal to "https://www.reuters.com/article/us-mideast-iran-tanker/iran-threatens-british-shipping-in-retaliation-for-tanker-seizure-idUSKCN1U00S5", it works fine. But when I specifically try:

query = 'SELECT EXISTS(SELECT * FROM table WHERE LINK = %s)'
c.execute(query, ["
https://www.reuters.com/article/brief-katanga-mining-receives-confirmati/brief-katanga-mining-receives-confirmation-from-kamoto-copper-co-that-armed-forces-of-drc-are-in-area-around-operations-of-kcc-idUSFWN24502R"])

I get:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 1: invalid start byte

This happened for another long URL. But the column type is mediumtext, and it's the same type I'm using for much longer strings.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
snapcrack
  • 1,761
  • 3
  • 20
  • 40

0 Answers0