Skip to content

Support networking data types #43

Closed

Activity

  1. added this to the 6.1 milestone on Aug 27, 2023
  2. modified the milestones: 6.1, 6.2 on Dec 5, 2024
  3. modified the milestones: 6.2, 6.3 on Nov 20, 2026
  4. Cito commented on Nov 22, 2026

    @Cito
    MemberAuthor

    Objects of the ipaddress module can now be passed as parameters in pg and pgdb, also inline (format_query(), query_formatted() with inline=True, and all parameters in pgdb) and as elements of arrays and records. Addresses and interfaces are adapted as inet, networks as cidr, as in psycopg 3. Arrays of inet and cidr (and of other types unknown to PyGreSQL, such as enums) can now also be written to table columns with DB.insert() and DB.update().

    The values are still returned as strings by default. To get ipaddress objects, set the new typecast functions:

    from pg.cast import cast_cidr, cast_inet  # or from pgdb.cast
    
    pg.set_typecast('inet', cast_inet)  # or pgdb.set_typecast
    pg.set_typecast('cidr', cast_cidr)

    Making this the default would be a breaking change, so I opened #119 for 7.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions