-
-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
Passing non-string parameters and default values can be achieved today using something like:
select *
where grade >= cast(%(grade)s as integer)
and is_allowed = cast(coalesce(nullif(%(is_allowed)s,''), 'true') as boolean)But this is not very readable. Would be nice to support some other patterns, for example:
select *
where grade >= %(grade)d
and is_allowed = %(is_allowed:true)bI know that psycopg2 supports only string parameters, but it does not seem too difficult to manually handle simple cases (like numbers and booleans) while still caring about SQL injections.
For now, I've proposed pull request #148 to refactor the named-parameter feature within the library, so that developpers can easily extend it according to their needs. That would be usefull in any case.
I think it would also be usefull that simple cases (like those mentionned above) be part of the library. What do you think?
Metadata
Metadata
Assignees
Labels
No labels