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?
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
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?
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