def import_from_libpq() -> None:
"""
- Import pq objects implementation from the best libpw wrapper available.
+ Import pq objects implementation from the best libpq wrapper available.
If an implementation is requested try to import only it, otherwise
try to import the best implementation available.
import ctypes
import ctypes.util
+import sys
from ctypes import Structure, CFUNCTYPE, POINTER
from ctypes import c_char, c_char_p, c_int, c_size_t, c_ubyte, c_uint, c_void_p
from typing import List, Tuple
from psycopg3.errors import NotSupportedError
-libname = ctypes.util.find_library("pq")
+if sys.platform == "win32":
+ libname = ctypes.util.find_library("libpq.dll")
+else:
+ libname = ctypes.util.find_library("pq")
if not libname:
raise ImportError("libpq library not found")
import re
import operator
+import sys
+
import pytest
try:
# Not available when testing the binary package
- libname = ctypes.util.find_library("pq")
+ if sys.platform == "win32":
+ libname = ctypes.util.find_library("libpq.dll")
+ else:
+ libname = ctypes.util.find_library("pq")
assert libname, "libpq libname not found"
return ctypes.pydll.LoadLibrary(libname)
except Exception as e: