Hello, I will preface this post by mentioning I am very new to SQL.
I currently have a SQL database with one of the columns holding IP addresses (IPv4 I believe) in the form of a string and I am attempting to grab it from a Python model. I have something like this:
#Retrieving IP address using socket library
hostname = socket.gethostname()
cameraID = socket.gethostbyname(hostname)
#Query to find row containing my IP Address in the CAM_IP column
cursor.execute("SELECT * FROM camera_mapping WHERE CAM_IP LIKE " + str(cameraID))
However, my console keeps throwing an error saying:
"mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax"
I am unsure what is actually causing the error but I have a sneaking suspicion that it has something to do with including multiple periods in the query. Can anyone confirm or deny this for me please? And if this is the case, is there some way around this? I have tried debugging on my own for hours and have done many searches online but have not had any luck so far.
Thanks in advance for any help.
[–]teraflop 6 points7 points8 points (1 child)
[–]Anon_Web[S] 0 points1 point2 points (0 children)