1

How can you load a table with INET ARRAY type?

cidr_table = db.Table('cidr_table', metadata,
        db.Column('range_name', db.String(255), nullable=False),
        db.Column('wide_range_cidr', postgresql.INET(), nullable=False),
        db.Column('used_cidr_list', postgresql.ARRAY(??????))
        )

I am trying to get the used_cidr_list to be an array of INET values which will be populated like [10.0.0.0/10, 10.1.0.0/16, and so on ]

How can i achieve that?

Thank you

1

1 Answer 1

2

There is the same method of using INET with or without flask

from sqlalchemy.dialects.postgresql import INET

class Hosts(db.Model):

    __tablename__ = 'hosts'

    host_id = db.Column(db.Integer(), db.Identity(), primary_key=True)

    host_name = db.Column(db.String(), nullable=False)

    host_ip_addresses = db.Column(db.ARRAY(INET()), nullable=True)

So in your case, It will be

    db.Column('used_cidr_list', db.ARRAY(INET()))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.