|
Python Connector for PostgreSQL Module additions - Python Connector for PostgreSQL |
|
The module provides several additional constructors and type objects for handling PostgreSQL-specific database types.
Numeric(weight, scale, sign, digits|value)Creates an object that holds a number with a very large number of digits.
Arguments
Return value
numeric object.Remarks
value argument can also contain special values Infinity, -Infinity, and NaN (or their string representations). These are adapted from the IEEE 754 standard, and represent the positive infinity, negative infinity, and not-a-number, respectively.Point(x, y|value)Creates an object that holds coordinates of a point on a plane.
Lseg(start, end|startx, starty, endx, endy|value)Creates an object that holds information about a line segment.
Arguments
start, end
point that specify the endpoints of the segment.startx, starty, endx, endy
int or float that specify the coordinates of the endpoints.value
[(x1, y1), (x2, y2)] where (x1, y1) and (x2, y2) are the respective endpoints, or a lseg object.Return value
lseg object.Line(a, b, c|value)Creates an object that holds information about a line.
Arguments
a, b, c
int or float that specify the coefficients of the linear equation ax + by + c = 0 that describes the line.value
{a, b, c} where a, b, and c are the respective coefficients, or a line object.Return value
line object.Remarks
a and b arguments must not both be zero.Path(points|value)Creates an object that holds an array of connected line segments.
Polygon(points|value)Creates an object that holds information about a polygon.
Box(upperright, lowerleft|upperrightx, upperrighty, lowerleftx, lowerlefty|value)Creates an object that holds information about the rectangle.
Arguments
upperright, lowerleft
point that specify the upper right and lower left corners of the rectangle.upperrightx, upperrighty, lowerleftx, lowerlefty
int or float that specify the coordinates of the rectangle corners.value
((x1, y1), (x2, y2)) where (x1, y1) and (x2, y2) are coordinates of two opposite corners of the rectangle, or a box object.Return value
box object.Remarks
Circle(center, radius|centerx, centery, radius|value)Creates an object that holds information about a circle.
Arguments
center
point that specifies the center point of the circle.radius
int or float that specifies the radius of the circle.centerx, centery, radius
int or float that specify coordinates of the center point of the circle and it's radius, respectively.value
<(x, y), r> where x and y are the center point coordinates and r is the radius, or a circle object.Return value
circle object.Vector(item)Creates an object that holds information about vectors.
Arguments
items
Return value
vector object.Halfvec(item)Creates an object that holds information about half-precision vectors.
Arguments
items
Return value
halfvec object.Sparsevec(count, elementcount, items)Creates an object that holds information about sparse vectors.
Arguments
count
elementcount
items
Return value
sparsevec object.numericThis type object describes an object that holds numbers with a very large number of digits. By default, this type object is used to fetch numeric or decimal columns from the cursor. You can also create a numeric object using the Numeric() constructor.
Attributes
digits
tuple of integers that specifies all the digits of a numeric object. Each element of the tuple contains four digits.weight
digits element that refers to the integer part of a numeric object.scale
numeric object.sign
numeric object is positive or negative, or has a special value.Examples
num1 = devart.postgresql.Numeric('-12345678.1234')
repr(num1)
'<devart.postgresql.numeric object at 0x...; weight=1, scale=4, sign=16384, digits=(1234, 5678, 1234)>'
The value 12345678.1234 is split into four-digit groups, which are then converted to integers. In this example, there are three digits elements: 1234, 5678, and 1234. The first two digits elements contain the integer part of the value, so the weight is 1. The fractional part of the value consists of four digits, so the scale is 4. Since the value is negative, the sign is 0x4000.
>>> num2 = devart.postgresql.Numeric('NaN')
repr(num2)
'<devart.postgresql.numeric object at 0x...; weight=0, scale=0, sign=49152, digits=()>'
Since the value is NaN, the numeric object contains no data other than the sign attribute, which is 0xC000.
pointThis type object describes an object that holds coordinates of a point on a plane. By default, this type object is used to fetch point columns from the cursor. You can also create a point object using the Point() constructor.
Attributes
x
y
lsegThis type object describes an object that holds information about a line segment. By default, this type object is used to fetch lseg columns from the cursor. You can also create a lseg object using the Lseg() constructor.
Attributes
start
end
lineThis type object describes an object that holds information about a line. By default, this type object is used to fetch line columns from the cursor. You can also create a line object using the Line() constructor.
Attributes
a
b
c
ax + by + c = 0 that describes the line.pathThis type object describes an object that holds an array of connected line segments. By default, this type object is used to fetch path columns from the cursor. You can also create a path object using the Path() constructor.
Attributes
points
list of endpoints of all the segments of the path.polygonThis type object describes an object that holds information about a polygon. By default, this type object is used to fetch polygon columns from the cursor. You can also create a polygon object using the Polygon() constructor.
Attributes
points
list of coordinates of all the vertexes of the polygon.boxThis type object describes an object that holds information about a rectangle. By default, this type object is used to fetch box columns from the cursor. You can also create a box object using the Box() constructor.
Attributes
upperright
lowerleft
circleThis type object describes an object that holds information about a circle. By default, this type object is used to fetch circle columns from the cursor. You can also create a circle object using the Circle() constructor.
Attributes
center
radius
vectorThis type object describes an object that holds information about a vector. By default, this type object is used to fetch vector columns from the cursor. You can also create a vector object using the Vector() constructor.
Attributes
items
halfvecThis type object describes an object that keeps information about half-precision vectors. By default, this type object is used to fetch halfvec columns from the cursor. You can also create a halfvec object using the Halfvec() constructor.
Attributes
items
sparsevecThis type object describes an object that stores information about sparse vectors. By default, this type object is used to fetch sparsevec columns from the cursor. You can also create a sparsevec object using the Sparsevec() constructor.
Attributes
count