Any alternatives to `INET6_ATON` SQL function, but in Python?

Question:

I want to convert a PHP program that uses MySQL to Python.
I found a way to store the database but I need to find a Pythonic alternative to the INET6_ATON SQL function.
Can someone help me, please?

Asked By: HGStyle

||

Answers:

Extending @tadman suggestion, you need to access .packed attribute to get bytes representation. E.g. ip_address("10.0.0.1").packed or ip_address("48f3::d432:1431:ba23:845f").packed.

[from Olvin Roght]

Thanks its doing exactly the same thing !

Docs of ipaddress.IPv4Address.packed:
https://docs.python.org/3/library/ipaddress.html#ipaddress.IPv4Address.packed

Answered By: HGStyle
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.