How to format SQLAlchemy ORM Postgresql CIDR contains (>>) query
I have a model defined with
from app import db
from sqlalchemy.dialects import postgresql
class TableIpAddress(db.Model):
__tablename__ = 'ipaddress'
idipaddress = db.Column( postgresql.UUID, primary_key=True )
ipaddress = db.Column( postgresql.CIDR, index=True, nullable=False )
I would like to do something like the following:
ip = '192.168.0.0/16'
db.session.query( TableIpAddress.ipaddress.op('<<')(ip) ).all()
This results in the key part of the error message:
sqlalchemy.exc.DBAPIError:
(ParameterError) could not pack parameter $1::pg_catalog.inet for transfer
The field is indeed a CIDR field. He doesn't seem to know how to package CIDR. Is there a way to force the parameter to be of the appropriate type?
+3
source to share
No one has answered this question yet
Check out similar questions: