Reading Data from MYSQL using Linux C

What is best way to get one row from a mysql table (with many columns) so I can use several several fields from that row for calculations in a C program?
After executing a succesful SELECT command using mysql_query, is there an alternative to using mysql_store_result?

MYSQL.CONNECTOR ISSUE WHILE CONNECTING MYSQL AND PYTHON

I am trying to connect MySQL(8.0.25) and python(3.8) using mysql.connector but getting the error:

mysql.connector.errors.ProgrammingError: 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Windows 10

same code working for pymysql.connect

the code used:

import mysql.connector as sql
s=sql.connect(host='localhost' ,user='root', password='<correct password>)
The password I entered is the one I use to successfully login to MySQL command line client.
Didn't get any real help in Google. Looking forward for Help. Thanks in advance.

MYSQL 8 Query Join Problem

I have the following query which has died after running over an hour on my local mysql 8 server:

UPDATE download
  LEFT JOIN lookup ON download.ip_address between lookup.start_ip AND lookup.end_ip
SET ref = (
    SELECT lookup.id FROM lookup WHERE download.ip_address between lookup.start_ip AND lookup.end_ip);

All ip fields are IPV4 and stored as unsigned integers and are indexed. The lookup table is approx. 3M rows, relating ip ranges to country, area, and city. The download table is approx. 2K rows. What I'm trying to do is get the id from the lookup table row that has the ip range that the download ip_address falls into.

Does someone see a problem with the query?

Endless loop in mysql function

Hello all.
I have a funtion in MYSQL to substruct days from a date.
This function seamsto work but some dates it times out.
This is my function

CREATE DEFINER=`root`@`localhost` FUNCTION `Calculater`(intrval int, req date) RETURNS date
    DETERMINISTIC
BEGIN
declare calculated date;
declare added int default  0;

Lbl_Loop: Loop
IF added=intrval then
leave lbl_loop;
End IF;
set calculated = DATE_SUB(req,interval 1 day);
IF weekday(calculated)<5  then
set added= added+1;
End If;
end loop;
RETURN calculated;
END

If I do select Calculater(1,"2020-02-04"); it works, but select Calculater(1,"2020-02-02"); it runs for a few seconds and My SQL times out.

Thanks in advance.

Values from PHP variables to MYSQL procedure

Hi all at Daniweb,

I'm quite new to PHP and I'm banging my head over this...

query 1 WORKS:

$query = "CALL procedure_is_a_great_way_to_let_db_do_some_work('1','6')";
//both 1 and 6 are IN parameters!

query 2 DOESN'T WORK:
$id_pictures = 1;
$id_names = 6;
$query = "CALL procedure_is_a_great_way_to_let_db_do_some_work('".$id_pictures."','".$id_names."')";
//both 1 and 6 are IN parameters!