3 ms·
There's no such thing as "parsing the string content according to... syntax". The string stored in the Excel file is what it is. The database does not "only al
by zahlman 2y ago
There's no such thing as "parsing the string content according to... syntax". The string stored in the Excel file is what it is.
The database does not "only allow strings enclosed by single quotes". Instead, it requires quotes around the string (and also escaping for embedded quotes - see https://stackoverflow.com/questions/1586560/ https://stackoverflow.com/questions/1586560/ - and possibly other characters) in the database query that is used to do the insertion. The database can store any string.
You should not attempt to format the string into the SQL query yourself. Instead, use a parameterized query. This is a question of understanding the library that you use from Python to interact with SQL - it has nothing to do with where the data came from.
You can and should use whatever library you like that will read the Excel file, in order to get the data. It's irrelevant to the problem you're actually trying to solve.
If there's a specific reason (imposed by a program that is using the database, not by MSSQL itself, which - again - doesn't care) that strings stored in the database need to be "sanitized" (i.e. altered to make sure they don't contain certain things, or meet other specific requirements), you need to identify the rules for this yourself, and implement them. This is "business logic", not part of the problem of working with SQL.