python postgres
Hi i want to store null value in a column.The column is nullable.The column value is not null always it depends on certain conditions.I dont want to write two queries in this case.I have tried None,null both but it gives me err开发者_如何学Cor saying worng type for double precision
You do not say which Python / PostGreSQL interface module you're using -- there are several, not all DB API compliant. In DB API compliant modules, the None
singleton is definitely the way to represent SQL NULL
s on the Python side of things -- the API docs leave no doubt:
SQL NULL values are represented by the Python None singleton on input and output.
Maybe you're erroneously using, e.g., 'None'
(with quotes making it a string, not the singleton None
object), just as I imagine you're using 'null'
with quotes in that erroneous attempt (if you didn't have quotes you'd get a NameError
-- unless you've defined a variable by that name, which I sure hope you haven't!-).
We can be more helpful if you don't hide from us all the crucial data you're hiding: which PostgreSQL interface module, what's the table's schema, a simple snippet that fails, etc.
精彩评论