I am passing the output from a sql query to again insert the data to ms sql db. If my data is null python / pyodbc is returning None instead of NULL. What is the best way to convert None to NULL when I am calling another query using the same data. Or a basic string transformation is the only way out ? Thanks Shakti
Asked
Active
Viewed 1.9k times
2 Answers
11
If you use a parameterized query to perform the insert then you won't have to worry about converting None
to NULL
(among other benefits). See my recent answer to a related question for details.

Community
- 1
- 1

Gord Thompson
- 116,920
- 32
- 215
- 418
-1
You could overwrite query function in way that None will be replace with "NULL"

Bartłomiej Bartnicki
- 1,067
- 2
- 14
- 30