Zc@s` ddlmZmZmZmZmZddlmZddl Z ddl m Z ddl m Z ddlmZddlmZmZmZddlmZmZdd lmZdd lmZmZmZmZmZmZm Z m!Z!dd l"m#Z#dd l$m%Z%dd l&m'Z'ddl(m)Z)ddl m*Z*ddlm+Z+ddl,Z,ddl-m.Z.dZ/edZ0defdYZ1e1Z2de3fdYZ4dZ5e5d\Z6Z7e5d\Z8Z9e5d\Z:Z;e5d\Z<Z=e5d\Z>Z?e5d\Z@ZAe5d\ZBZCe5d \ZDZEe5d!\ZFZGe5d"\ZHZIe5d#\ZJZKe5d$\ZLZMe5d%\ZNZOd&d' d&d'f\ZPZQd&d( d&d(f\ZRZSd&d) d&d)f\ZTZUd*eVfd+YZWd,eVfd-YZXd.eXfd/YZYd0eXfd1YZZd2eZfd3YZ[d4eZfd5YZ\d6eZfd7YZ]d8eZfd9YZ^d:eZfd;YZ_d<eZfd=YZ`d>e`fd?YZad@e_fdAYZbdBe_fdCYZcdDe fdEYZddFZedGZfdHZgdIZhdJZidKZjdLZkeryedZlnemZldZndMZoedNZpedOedPfZqdQZredRdMdMZsesjtdSe2Zue'esjvZwd&d)dMZxdexdMZydTZzdUZ{dVZ|dWZ}dXZ~dYZdZZd[Zd\Zd]Zd^Zd_Zd`ZdaZdbZdcZddZdeZerdfZn dgZdhZdiZedjZedkZdlZe6dZedkZdmZdnZdofdpYZerLeje_nedqZedrZedsZedtZeduZedvZedwZedxZedyZedzZed{Zed|Zed}Zed~ZedZedZedZedZedZedZedZedZedZedwZedZedsZedZedxZedZedyZeddZeeZeeZeeZeeZeeee6dZedsZedZedsZedyZedZedxZedZedZedZedZedZedZedZedrZedZedvZedwZeeeeedeedegdZde3fdYZidd6dd6dd6dd6Zied6ed6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6ZdZdZdZdZdZdZdS(i(t timedeltatdatetimettzinfotdatettime(twarnN(tpack(tmd5(tDecimal(tdequet defaultdictt OrderedDict(tcounttislice(tmap(tbtPY2t integer_typestnextt text_typetut binary_typet itervalues(tUUID(tdeepcopy(ttimegm(t LooseVersion(tStruct(t localtime(tloadssMathieu FenniakitUTCcBs#eZdZdZdZRS(cCstS(N(tZERO(tselftdt((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt utcoffset:scCsdS(NR((R R!((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyttzname=scCstS(N(R(R R!((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pytdst@s(t__name__t __module__R"R#R$(((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR8s  tIntervalcBseZdZddddZdZdZdZedeZedeZ edeZ d Z d Z d Z RS( s An Interval represents a measurement of time. In PostgreSQL, an interval is defined in the measure of months, days, and microseconds; as such, the pg8000 interval type represents the same information. Note that values of the :attr:`microseconds`, :attr:`days` and :attr:`months` properties are independently measured and cannot be converted to each other. A month may be 28, 29, 30, or 31 days, and a day may occasionally be lengthened slightly by a leap second. .. attribute:: microseconds Measure of microseconds in the interval. The microseconds value is constrained to fit into a signed 64-bit integer. Any attempt to set a value too large or too small will result in an OverflowError being raised. .. attribute:: days Measure of days in the interval. The days value is constrained to fit into a signed 32-bit integer. Any attempt to set a value too large or too small will result in an OverflowError being raised. .. attribute:: months Measure of months in the interval. The months value is constrained to fit into a signed 32-bit integer. Any attempt to set a value too large or too small will result in an OverflowError being raised. icCs||_||_||_dS(N(t microsecondstdaystmonths(R R(R)R*((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt__init__js  cCsVt|tstdn4t|ko5tknsItdn ||_dS(Ns$microseconds must be an integer types6microseconds must be representable as a 64-bit integer(t isinstanceRt TypeErrortmin_int8tmax_int8t OverflowErrort _microseconds(R tvalue((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt_setMicrosecondsos  cCsVt|tstdn4t|ko5tknsItdn ||_dS(Nsdays must be an integer types.days must be representable as a 32-bit integer(R,RR-tmin_int4tmax_int4R0t_days(R R2((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt_setDaysxs  cCsVt|tstdn4t|ko5tknsItdn ||_dS(Nsmonths must be an integer types0months must be representable as a 32-bit integer(R,RR-R4R5R0t_months(R R2((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt _setMonthss  cCs|jS(N(R1(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pytscCs|jS(N(R6(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR:scCs|jS(N(R8(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR:scCsd|j|j|jfS(Ns,(R*R)R((R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt__repr__scCsO|dk oNt|toN|j|jkoN|j|jkoN|j|jkS(N(tNoneR,R'R*R)R((R tother((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt__eq__s$cCs|j| S(N(R>(R R=((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt__neq__s(R%R&t__doc__R+R3R7R9tpropertyR(R)R*R;R>R?(((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR'Gs!   cCs td|}|j|jfS(Nt!(RRt unpack_from(tfmttstruc((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt pack_funcsstithtqtdtftiiitiitqiitdiitihihihtcitbhtcccciiii?tWarningcBseZdZRS(sGeneric exception raised for important database warnings like data truncations. This exception is not currently used by pg8000. This exception is part of the `DBAPI 2.0 specification `_. (R%R&R@(((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRTstErrorcBseZdZRS(sGeneric exception that is the base exception of all other error exceptions. This exception is part of the `DBAPI 2.0 specification `_. (R%R&R@(((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRUstInterfaceErrorcBseZdZRS(siGeneric exception raised for errors that are related to the database interface rather than the database itself. For example, if the interface attempts to use an SSL connection but the server refuses, an InterfaceError will be raised. This exception is part of the `DBAPI 2.0 specification `_. (R%R&R@(((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRVst DatabaseErrorcBseZdZRS(sGeneric exception raised for errors that are related to the database. This exception is currently never raised by pg8000. This exception is part of the `DBAPI 2.0 specification `_. (R%R&R@(((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRWst DataErrorcBseZdZRS(sGeneric exception raised for errors that are due to problems with the processed data. This exception is not currently raised by pg8000. This exception is part of the `DBAPI 2.0 specification `_. (R%R&R@(((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRXstOperationalErrorcBseZdZRS(s= Generic exception raised for errors that are related to the database's operation and not necessarily under the control of the programmer. This exception is currently never raised by pg8000. This exception is part of the `DBAPI 2.0 specification `_. (R%R&R@(((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRYstIntegrityErrorcBseZdZRS(s Generic exception raised when the relational integrity of the database is affected. This exception is not currently raised by pg8000. This exception is part of the `DBAPI 2.0 specification `_. (R%R&R@(((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRZst InternalErrorcBseZdZRS(sNGeneric exception raised when the database encounters an internal error. This is currently only raised when unexpected state occurs in the pg8000 interface itself, and is typically the result of a interface bug. This exception is part of the `DBAPI 2.0 specification `_. (R%R&R@(((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR[stProgrammingErrorcBseZdZRS(s&Generic exception raised for programming errors. For example, this exception is raised if more parameter fields are in a query string than there are available parameters. This exception is part of the `DBAPI 2.0 specification `_. (R%R&R@(((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR\ stNotSupportedErrorcBseZdZRS(sGeneric exception raised in case a method or database API was used which is not supported by the database. This exception is part of the `DBAPI 2.0 specification `_. (R%R&R@(((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR]stArrayContentNotSupportedErrorcBseZdZRS(s Raised when attempting to transmit an array where the base type is not supported for binary data transfer by the interface. (R%R&R@(((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR^stArrayContentNotHomogenousErrorcBseZdZRS(sl Raised when attempting to transmit an array that doesn't contain only a single type of object. (R%R&R@(((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR_'st!ArrayDimensionsNotConsistentErrorcBseZdZRS(sf Raised when attempting to transmit an array that has inconsistent multi-dimension sizes. (R%R&R@(((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR`/stByteacBseZdZRS(sBytea is a str-derived class that is mapped to a PostgreSQL byte array. This class is only used in Python 2, the built-in ``bytes`` type is used in Python 3. (R%R&R@(((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRa7scCst|||S(sConstuct an object holding a date value. This function is part of the `DBAPI 2.0 specification `_. :rtype: :class:`datetime.date` (R(tyeartmonthtday((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pytDate?scCst|||S(sConstruct an object holding a time value. This function is part of the `DBAPI 2.0 specification `_. :rtype: :class:`datetime.time` (R(thourtminutetsecond((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pytTimeJscCst||||||S(sConstruct an object holding a timestamp value. This function is part of the `DBAPI 2.0 specification `_. :rtype: :class:`datetime.datetime` (tDatetime(RbRcRdRfRgRh((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt TimestampUscCstt|d S(sConstruct an object holding a date value from the given ticks value (number of seconds since the epoch). This function is part of the `DBAPI 2.0 specification `_. :rtype: :class:`datetime.date` i(ReR(tticks((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt DateFromTicks`s cCstt|dd!S(sConstruct an objet holding a time value from the given ticks value (number of seconds since the epoch). This function is part of the `DBAPI 2.0 specification `_. :rtype: :class:`datetime.time` ii(RiR(Rl((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt TimeFromTicksls cCstt|d S(s Construct an object holding a timestamp value from the given ticks value (number of seconds since the epoch). This function is part of the `DBAPI 2.0 specification `_. :rtype: :class:`datetime.datetime` i(RkR(Rl((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pytTimestampFromTicksxs cCstrt|S|SdS(sConstruct an object holding binary data. This function is part of the `DBAPI 2.0 specification `_. :rtype: :class:`pg8000.types.Bytea` for Python 2, otherwise :class:`bytes` N(RRa(R2((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pytBinarys it tALTERtCREATEcs'd}d}d}d}d}t}t}gg} tdtd} |} d} xt|D]\} }| dt|kr|| d}nd}| |krY|dkr| j|| dkr|} qV|} q|d kr| j||} q|d kr3|d kr3| jt| q|d kr[|d kr[| jdq|dkr|d kr|} jdq|dkr|dkr|dkr|} jdq|dkrI|dkrId}|rt}| j|qV|dkrt}qV|dkr:|} | jt| qVt dq| j|n| |kr|dkr| j||rt}q|dkrt}q|} q| j|n(| |kr|d kr|} | j|q| j|n| |krC|dkr3| dkr3| j||} q| j|n| |kr|dkr dc|7<|dks|j r|dkr|} y?j ddd}| jdt |dd=Wq t k r| jdt tq Xqq|dkr| dkr|dkr|} y?j ddd}| jdt |dd=Wqt k r| jdt tqXq|dkrqdc|7s(ttuple(R(t placeholders(Rs+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRs(sformatR(snumericRzsformat(tFalseRR R<t enumeratetlentappendRtTrueRVtisalnumtindexRut ValueErrortjoin(tstyletquerytOUTSIDEt INSIDE_SQt INSIDE_QIt INSIDE_ESt INSIDE_PNtin_quote_escapetin_param_escapet output_queryt param_idxtstatetprev_cRGtctnext_ctpidxR((Rs+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pytconvert_paramstyles          $                  %  '   $      iRcCsdt||d}yttd|SWn5tk r_|tkrHdS|tkrXdS|SnXdS(NiR(tinfinitys -infinity(tq_unpacktEPOCHt TimedeltaR0tINFINITY_MICROSECONDStMINUS_INFINITY_MICROSECONDS(tdatatoffsettlengthtmicros((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyttimestamp_recv_integer*s   cCstjtt||dS(Ni(Rjtutcfromtimestampt EPOCH_SECONDStd_unpack(RRR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyttimestamp_recv_float8scCs+ttt|jtd|jS(Ng.A(tq_packtintRt timetupleRt microsecond(tv((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyttimestamp_send_integer=scCs%tt|j|jdtS(Ng.A(td_packRRRR(R((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyttimestamp_send_floatCscCst|jtjddS(NR(Rt astimezonetutctreplaceR<(R((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyttimestamptz_send_integerGscCst|jtjddS(NR(RRRRR<(R((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyttimestamptz_send_floatMscCsdt||d}yttd|SWn5tk r_|tkrHdS|tkrXdS|SnXdS(NiR(Rs -infinity(RtEPOCH_TZRR0RR(RRRR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyttimestamptz_recv_integerWs   cCst|||jdtS(NR(RRR(RRR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyttimestamptz_recv_floatdscCsr|j}y|t|jd7}Wntk r7nXy |j}Wntk r^d}nXt||j|S(Ng.Ai(R(RtsecondstAttributeErrorR*tqii_packR)(RR(R*((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pytinterval_send_integerhs     cCsp|jdd}y||j7}Wntk r5nXy |j}Wntk r\d}nXt||j|S(Ng@@i(R(RRR*tdii_packR)(RRR*((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pytinterval_send_floatws    cCs]t||\}}}|dkrIt|d\}}t|||St|||SdS(Nig.A(t qii_unpacktdivmodRR'(RRRR(R)R*RR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pytinterval_recv_integers  cCskt||\}}}|dkrIt|d\}}t|||Stt|dd||SdS(Nig.Ai(t dii_unpackRRR'R(RRRRR)R*tsecsR(((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pytinterval_recv_floats  cCst||dS(Ni(R(RRR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt int8_recvscCst||dS(Ni(th_unpack(RRR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt int2_recvscCst||dS(Ni(ti_unpack(RRR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt int4_recvscCst||dS(Ni(tf_unpack(RRR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt float4_recvscCst||dS(Ni(R(RRR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt float8_recvscCs|S(N((R((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt bytea_sendscCst||||!S(N(Ra(RRR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt bytea_recvscCs||||!S(N((RRR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRscCs|jS(N(tbytes(R((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt uuid_sendscCstd||||!S(NR(R(RRR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt uuid_recvsstcCs|r tStS(N(tTRUEtFALSE(R((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt bool_sendscCstS(N(tNULL(R((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt null_sendscCst||||!S(N(R(RRR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pytint_instCursorcBseZdZdZdZdZedZedZedZ dZ dddZ d Z d Zdd Zd Zd ZdZdZddZdZRS(s<A cursor object is returned by the :meth:`~Connection.cursor` method of a connection. It has the following attributes and methods: .. attribute:: arraysize This read/write attribute specifies the number of rows to fetch at a time with :meth:`fetchmany`. It defaults to 1. .. attribute:: connection This read-only attribute contains a reference to the connection object (an instance of :class:`Connection`) on which the cursor was created. This attribute is part of a DBAPI 2.0 extension. Accessing this attribute will generate the following warning: ``DB-API extension cursor.connection used``. .. attribute:: rowcount This read-only attribute contains the number of rows that the last ``execute()`` or ``executemany()`` method produced (for query statements like ``SELECT``) or affected (for modification statements like ``UPDATE``). The value is -1 if: - No ``execute()`` or ``executemany()`` method has been performed yet on the cursor. - There was no rowcount associated with the last ``execute()``. - At least one of the statements executed as part of an ``executemany()`` had no row count associated with it. - Using a ``SELECT`` query statement on PostgreSQL server older than version 9. - Using a ``COPY`` query statement on PostgreSQL server version 8.1 or older. This attribute is part of the `DBAPI 2.0 specification `_. .. attribute:: description This read-only attribute is a sequence of 7-item sequences. Each value contains information describing one result column. The 7 items returned for each column are (name, type_code, display_size, internal_size, precision, scale, null_ok). Only the first two values are provided by the current implementation. This attribute is part of the `DBAPI 2.0 specification `_. cCs4||_d|_d|_d|_t|_dS(Nii(t_ct arraysizeR<tpst _row_countR t _cached_rows(R t connection((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR+ s     cCs|S(N((R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt __enter__scCs|jdS(N(tclose(R texc_typet exc_valuet traceback((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt__exit__scCstddd|jS(Ns'DB-API extension cursor.connection usedt stackleveli(RR(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRscCs|jS(N(R(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pytrowcountscCs |jS(N(t_getDescription(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR:!sc Cs{|jdkrdS|jd}t|dkr6dSg}x8|D]0}|j|d|ddddddfqCW|S(Ntrow_descitnamettype_oid(RR<RR(R Rtcolumnstcol((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR#s  (cCsyV||_|jj r?|jj r?|jj|ddn|jj|||WnXtk r}|jdkrtdq|jjdkrtdq|nXdS(seExecutes a database operation. Parameters may be provided as a sequence, or as a mapping, depending upon the value of :data:`pg8000.paramstyle`. This method is part of the `DBAPI 2.0 specification `_. :param operation: The SQL statement to execute. :param args: If :data:`paramstyle` is ``qmark``, ``numeric``, or ``format``, this argument should be an array of parameters to bind into the statement. If :data:`paramstyle` is ``named``, the argument should be a dict mapping of parameters. If the :data:`paramstyle` is ``pyformat``, the argument value may be either an array or a mapping. :param stream: This is a pg8000 extension for use with the PostgreSQL `COPY `_ command. For a COPY FROM the parameter must be a readable file-like object, and for COPY TO it must be writable. .. versionadded:: 1.9.11 sbegin transactions Cursor closedsconnection is closedN( tstreamRtin_transactiont autocommittexecuteR<RRVt_sock(R t operationtargsRte((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR4s cCs\g}x.|D]&}|j|||j|jq Wd|krIdn t||_dS(s1Prepare a database operation, and then execute it against all parameter sequences or mappings provided. This method is part of the `DBAPI 2.0 specification `_. :param operation: The SQL statement to execute :param parameter_sets: A sequence of parameters to execute the statement with. The values in the sequence should be sequences or mappings of parameters, the same as the args argument of the :meth:`execute` method. iN(RRRtsum(R Rt param_setst rowcountst parameters((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt executemany]s  cCs_yt|SWnJtk r"dStk r>tdntk rZtdnXdS(s Fetch the next row of a query result set. This method is part of the `DBAPI 2.0 specification `_. :returns: A row as a sequence of field values, or ``None`` if no more rows are available. s#attempting to use unexecuted cursorN(Rt StopIterationR<R-R\R(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pytfetchoners    cCsPy,tt||dkr!|jn|SWntk rKtdnXdS(sFetches the next set of rows of a query result. This method is part of the `DBAPI 2.0 specification `_. :param size: The number of rows to fetch when called. If not provided, the :attr:`arraysize` attribute value is used instead. :returns: A sequence, each entry of which is a sequence of field values making up a row. If no more rows are available, an empty sequence will be returned. s#attempting to use unexecuted cursorN(RR R<RR-R\(R tnum((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt fetchmanys ) cCs2yt|SWntk r-tdnXdS(s$Fetches all remaining rows of a query result. This method is part of the `DBAPI 2.0 specification `_. :returns: A sequence, each entry of which is a sequence of field values making up a row. s#attempting to use unexecuted cursorN(RR-R\(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pytfetchalls  cCs d|_dS(sCloses the cursor. This method is part of the `DBAPI 2.0 specification `_. N(R<R(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRscCs|S(soA cursor object is iterable to retrieve the rows from a query. This is a DBAPI 2.0 extension. ((R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt__iter__scCsdS(sThis method is part of the `DBAPI 2.0 specification `_, however, it is not implemented by pg8000. N((R tsizes((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt setinputsizesscCsdS(sThis method is part of the `DBAPI 2.0 specification `_, however, it is not implemented by pg8000. N((R tsizetcolumn((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt setoutputsizescCsxy|jjSWn`tk rs|jdkr?tdqtt|jddkrgtdqttnXdS(NsA query hasn't been issued.Ris no result set(Rtpopleftt IndexErrorRR<R\RR(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt__next__s N(R%R&R@R+RRRARRt descriptionRR<RRR R R RR RRR(((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRs$3    )        tNtRtStKtZtTRxtDtCt1t2t3RtntttARtGtHtItBtPRtXRcCs|tt|d|S(Ni(ti_packR(tcodeR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pytcreate_messagestMtWtFtLs[] 'us{}it ConnectioncBseZedZedZedZedZedZedZedZ edZ edZ d Z d Z d Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"d Z#d!Z$d"Z%d#Z&d$Z'd%Z(d&Z)d'Z*d(Z+d)Z,d*Z-d+Z.d,Z/d-Z0d.Z1d/Z2e3d0Z4e3d1Z5d2Z6RS(3cCs |jtS(N(t _getErrorRT(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR:!scCs |jtS(N(R3RU(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR:"scCs |jtS(N(R3RV(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR:#scCs |jtS(N(R3RW(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR:$scCs |jtS(N(R3RY(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR:%scCs |jtS(N(R3RZ(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR:&scCs |jtS(N(R3R[(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR:'scCs |jtS(N(R3R\(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR:(scCs |jtS(N(R3R](R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR:*scCstd|jdd|S(Ns#DB-API extension connection.%s usedRi(RR%(R terror((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR3,sc $s d_tdtdtdtdtdtdtdf_td d _td d _td d _|dkrtd nt |t r|j d_ n |_ t |t r|j d_ n |_ t_d_td _d _y|dkrb|dk rbtjtjtj_nT|dk rttdstdntjtjtj_n tdt r|dk rjj|n|dkr |dk r jj||fn|dk r,jj|n|ryqddl} jjt ddjj!d} | tdkr| j"j_n tdWqt#k rtdqXnjj$dd_%Wn2tj&k r} jj'td| nXj%j(_)j%j*_+j%j,_-d_.fd} fd}fd}fd}t/t0t1t2t3dt3d it4d!6fd"}fd#}fd$}tr fd%d&}fd'}n'fd(d)}fd*}fd+}fd,}fd-}fd.}tfd/i&t5|fd06t5t6fd16t5fd26t5t7fd36t5t8fd46t9|fd56t5t:fd66t5fd76t9t;fd86t9t;fd96t9|fd:6t5t<fd;6t5t=fd<6t5fd=6t9fd>6t5|fd?6t5|fd@6t5|fdA6t5|fdB6t5|fdC6t5|fdD6t5|fdE6t5|fdF6t5|fdG6t5|fdH6t5fdI6t5fdJ6t9|fdK6t9|fdL6t5t>fdM6t5t?fdN6t5t@fdO6t9|fdP6t5|fdQ6t9|fdR6t5fdS6t5tAfdT6t9|fdU6_Bidt5tCftDd6d0t5tEftF6d3t5tGfd36d4t5tHfd46d6t5tIfd66d<t5tJftK6dKt9|ftL6dLt9|ftM6dMt5tNfdM6dNt5tOfdN6dOt5tPftQ6dOt5tPftR6dRt9|ft46dTt5tSftT6_UijVtW6jXtY6jXtZ6j[t\6_]trd1t5t^fjUt_scsD||||!jj}d|kr6|tS|SdS(Nt/(RLRCR(RRRtinet_str(RsRvR (s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pytinet_inAs    ieitusert databasetapplication_nameii(RCRt_commands_with_countR t notificationstnoticestparameter_statusesR<RVR,RRBtusertpasswordRRt_xidR t_cacheststatement_numbertsockettAF_INETt SOCK_STREAMt_usockthasattrR?R\Rt settimeouttconnecttssltsendalltii_packtrecvt wrap_sockett ImportErrortmakefileRR4Rtflusht_flushtreadt_readtwritet_writet_backend_key_dataR>R[RtordRRt FC_BINARYRRRRrRRRRRRRRRVRttypeRtboolRth_packR+RtfloatRRRRRRR'RRtpy_typestinspect_datetimeRjt array_inspectRZRt inspect_intRt inspect_funcsRRaRutlongRt ipaddressRsRtRuRvRwRxthandle_NOTICE_RESPONSEtNOTICE_RESPONSEthandle_AUTHENTICATION_REQUESTtAUTHENTICATION_REQUESTthandle_PARAMETER_STATUStPARAMETER_STATUSthandle_BACKEND_KEY_DATAtBACKEND_KEY_DATAthandle_READY_FOR_QUERYtREADY_FOR_QUERYthandle_ROW_DESCRIPTIONtROW_DESCRIPTIONthandle_ERROR_RESPONSEtERROR_RESPONSEthandle_EMPTY_QUERY_RESPONSEtEMPTY_QUERY_RESPONSEthandle_DATA_ROWtDATA_ROWthandle_COMMAND_COMPLETEtCOMMAND_COMPLETEthandle_PARSE_COMPLETEtPARSE_COMPLETEthandle_BIND_COMPLETEt BIND_COMPLETEthandle_CLOSE_COMPLETEtCLOSE_COMPLETEthandle_PORTAL_SUSPENDEDtPORTAL_SUSPENDEDthandle_NO_DATAtNO_DATAthandle_PARAMETER_DESCRIPTIONtPARAMETER_DESCRIPTIONthandle_NOTIFICATION_RESPONSEtNOTIFICATION_RESPONSEthandle_COPY_DONEt COPY_DONEthandle_COPY_DATAt COPY_DATAthandle_COPY_IN_RESPONSEtCOPY_IN_RESPONSEthandle_COPY_OUT_RESPONSEtCOPY_OUT_RESPONSEt message_typest bytearrayt NULL_BYTERNRRtcursort_cursort ci_unpackR($R Rthostt unix_socktporttdatabaseRRttimeouttapplication_namet sslmoduletrespRRDRFRGRHRTReRfRkRlRnRoRpRqRtRuRwRxRyR|tprotocoltvalR,tdata_len((RRRsRvR RhRSs+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR+2s $$               *                                            .                     $      % csftfd|jtD}t|}|tdkrSt|_nt|_dS(Nc3sA|]7}|tdkr|d |djjfVqdS(RiN(RRLRC(RR(R (s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pys st28000(R tsplitRRt RESPONSE_CODERVR4R\(R RRtmsgtexc_args((R s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRs  cCstd|_dS(Nsquery was empty(R\R4(R RR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRscCsdS(N((R RR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRscCsdS(N((R RR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRscCsdS(N((R RR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRscCsdS(N((R RR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRscCsdS(N((R RR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRscCs t|_dS(N(Rt _copy_done(R RR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRscCs4t|\}}|jdkr0tdndS(Ns7An output stream is required for the COPY OUT response.(t bh_unpackRR<RV(R RRt is_binarytnum_cols((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRscCs|jj|dS(N(RR(R RR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRscCs3t|\}}|jdkr0tdntrxtr|jjd}|s[Pn|jtt t |d|j||j q9Wnqt d}xbtr |jj |}|dkrPn|jtt |d|j|| |j qW|jt|jt|j dS(Ns5An input stream is required for the COPY IN response.i ii(RRR<RVRRRRRR+RRRtreadintot COPY_DONE_MSGtSYNC_MSG(R RRRRtbffrt bytes_read((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRs.  !      cCst|d}d}|jt||}||||!jd}||d7}|jt||}|jj||fdS(Niitasciii(RtfindRRLRR(R RRt backend_pidRPtnullt condition((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRscCs t|S(sCreates a :class:`Cursor` object bound to this connection. This function is part of the `DBAPI 2.0 specification `_. (R(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRscCs|j|jdddS(sCommits the current database transaction. This function is part of the `DBAPI 2.0 specification `_. tcommitN(RRR<(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRscCs'|js dS|j|jdddS(sRolls back the current database transaction. This function is part of the `DBAPI 2.0 specification `_. Ntrollback(RRRR<(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRs cCsz{y(|jt|j|jjWnLtk rJtdn0tk rftdntj k rynXWd|j jd|_XdS(sCloses the database connection. This function is part of the `DBAPI 2.0 specification `_. sconnection is closedN( Rt TERMINATE_MSGRRRRRVRRR4RR<(R ((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR s     cCset|d}|dkrnB|dkrm|jdkrItdn|jt|jt|jn|dkrtdj t |d}|jdkrtdntdt t |j|j j jd |j jd }|jt|t|jnC|dkrGtdt|dntdt|ddS(NiisGserver requesting password authentication, but no password was providediRisKserver requesting MD5 password authentication, but no password was providedRRiiiii sAuthentication method s not supported by pg8000.s not recognized by pg8000.(iiiiii (RRR<RVt _send_messagetPASSWORDRRRRt cccc_unpackRRt hexdigestRBRu(R RRt auth_codetsalttpwd((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR!s4       "     cCs|tk|_dS(N(tIDLER(R RR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRYscCs ||_dS(N(R(R RR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR]scCs)|jdkr|jdS|jdSdS(NiZi(RR<R(R R2((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR`s cCsyt|kotknr'|jdSt|ko>tknrN|jdSt|koetknru|jdSdS(Niii(tmin_int2tmax_int2RR4R5R.R/(R R2((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRfs   cCsg}x|D]}t|}y|j|j|Wq tk ry|j|j||Wqtk r}tdt|dqXq Xq Wt|S(Nstype snot mapped to pg type(RRRtKeyErrorRR]RuR(R RctparamsR2ttypR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt make_paramsns   #c Cst|d}d}xt|D]}|||jt|!}|t|d7}ttdt||}||d <|d 7}|jd j ||j |d\|d <|dR[t ihihih_unpackRRRV(R RRR RPRGRtfield((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR|s  cs_|dkrd}ntj}j|}y|d|\}}Wn:tk rt||\}}||f|d|st param_funcscss|]}|dVqdS(iN((RRv((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pys siisconnection is closedc3s$|]}j|ddVqdS(RiN(RV(RRK(R (s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pys scss|]}|dVqdS(RN((RRK((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pys st input_funcsRBRHtbind_1tbind_2(()R<tpg8000t paramstyleRRRR RRuRRBRRRRNRCRRR+RtPARSEtDESCRIBEt STATEMENTRRRRRRVthandle_messagesRtmax_prepared_statementsRtclose_prepared_statementtclearRRR[RtBINDt send_EXECUTE(R RRRRtcacheRRRRtkeyRtstatement_nameRt param_fcsRtoidtfct send_funcRt output_fcRtretvalR2((R s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRs           )   2"         cCsyH|j||jtt|d|j||jtWnVtk r}t|dkr{tdq|ntk rtdnXdS(Niswrite to closed filesconnection is closed(RR+Rt FLUSH_MSGRRuRVR(R R,RR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRs    cCs|jt|jtdS(N(Rt EXECUTE_MSGR-(R R((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR#%s cCsdS(N((R RR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR/scCs|d jt}|d}||jkrit|d}|jdkrW||_qi|j|7_n|tkrxTt|jD]@}x)t|dD]}|j|dqW|dj qWndS(NiiRR( Rt BINARY_SPACERRRt DDL_COMMANDSRRR R!(R RRRctcommandt row_countR$R((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR2s   cCsd}g}xq|jdD]b}t||d}|d7}|dkrY|jdq|j||||||7}qW|jj|dS(NiRiii(RRRR<R(R RRtdata_idxtrowRtvlen((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRBs  cCs{d}|_xL|tkr[t|jd\}}|j||j|d|qW|jdk rw|jndS(Nii(R<R4RRRR(R RR,R((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyROs  %cCs?|jtt||jt|j|j|jdS(N(RtCLOSERRRRRR(R R((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR ]s  cCs-|jjtd|jtDdS(Ncss&|]}|dd!|dfVqdS(iiN((RR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pys js(RRR>RR(R RR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRhs cCs|jt}|| ||dd!}}|jj||f|tdkr|jdj}tj|||_ n|tdkr|tdkr8dt t f|j d`_. sbegin transactionN(RRRRR<(R RX((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt tpc_begins  cCs.d|jdf}|j|j|ddS(sPerforms the first phase of a transaction started with .tpc_begin(). A ProgrammingError is be raised if this method is called outside of a TPC transaction. After calling .tpc_prepare(), no statements can be executed until .tpc_commit() or .tpc_rollback() have been called. This function is part of the `DBAPI 2.0 specification `_. sPREPARE TRANSACTION '%s';iN(RRRR<(R RI((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt tpc_prepares cCs|dkr|j}n|dkr3tdnzV|j}t|_||jkr~|j|jd|dfdn |jWd||_Xd|_dS(s%When called with no arguments, .tpc_commit() commits a TPC transaction previously prepared with .tpc_prepare(). If .tpc_commit() is called prior to .tpc_prepare(), a single phase commit is performed. A transaction manager may choose to do this if only a single resource is participating in the global transaction. When called with a transaction ID xid, the database commits the given transaction. If an invalid transaction ID is provided, a ProgrammingError will be raised. This form should be called outside of a transaction, and is intended for use in recovery. On return, the TPC transaction is ended. This function is part of the `DBAPI 2.0 specification `_. s.Cannot tpc_commit() without a TPC transaction!sCOMMIT PREPARED '%s';iN( R<RR\RRt tpc_recoverRRR(R RXtprevious_autocommit_mode((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt tpc_commit$s        cCs|dkr|j}n|dkr3tdnzV|j}t|_||jkr~|j|jd|dfdn |jWd||_Xd|_dS(sDWhen called with no arguments, .tpc_rollback() rolls back a TPC transaction. It may be called before or after .tpc_prepare(). When called with a transaction ID xid, it rolls back the given transaction. If an invalid transaction ID is provided, a ProgrammingError is raised. This form should be called outside of a transaction, and is intended for use in recovery. On return, the TPC transaction is ended. This function is part of the `DBAPI 2.0 specification `_. s9Cannot tpc_rollback() without a TPC prepared transaction!sROLLBACK PREPARED '%s';iN( R<RR\RRR[RRR(R RXR\((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyt tpc_rollbackKs        cCsjzY|j}t|_|j}|jdg|D]}|jd|dd^q5SWd||_XdS(sReturns a list of pending transaction IDs suitable for use with .tpc_commit(xid) or .tpc_rollback(xid). This function is part of the `DBAPI 2.0 specification `_. s!select gid FROM pg_prepared_xactsiRN(RRRRRX(R R\tcursR4((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR[os    .(7R%R&RARTRURVRWRYRZR[R\R]R3R+RRRRRRRRRRRRRRRRRRRRRR RRRR#RRRRR RRRRXRYRZR<R]R^R[(((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyR2sj   W         "    8            . c    ' $iiiiiiiit mule_internalteuc_twtgb2312teuc_cntis8859_5t iso_8859_5tis8859_6t iso_8859_6tis8859_7t iso_8859_7tis8859_8t iso_8859_8tkoi8_rtkoi8s iso8859-1tlatin1t iso8859_2tlatin2t iso8859_3tlatin3t iso8859_4tlatin4t iso8859_9tlatin5t iso8859_10tlatin6t iso8859_13tlatin7t iso8859_14tlatin8t iso8859_15tlatin9Rt sql_asciitcp886twin866tcp874twin874tcp1250twin1250tcp1251twin1251tcp1252twin1252tcp1253twin1253tcp1254twin1254tcp1255twin1255tcp1256twin1256tcp1257twin1257tcp1258twin1258sutf-8Rgccsoxht|D]Z\}}t|trYx<t|D]\}}}|||fVq5Wq |||fVq WdS(N(RR,RZRI(RQRGRRLti2tv2((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRIs cCs+x$t|D]}|dk r |Sq WdS(N(RER<(RQR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRMs ccsHxA|D]9}t|tr;x!t|D] }|Vq)Wq|VqWdS(N(R,RZRE(RQRR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyREs   cCst|dkr|d}t|trt|}t|}xG|D]?}t|}t||ksz||krJtdqJqJW|g}|j||Sx/|D]$}t|trtdqqWngS(Nisarray dimensions not consistent(RR,RZRAR`RN(RQtv0treq_lentreq_inner_lengthsRt inner_lengthsR,((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRAs$        cCs+x$t|D]}|dkr tSq WtS(N(RER<RR(RQR((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRBs cCsat|}|dkrZ|d}t|trZt|g}|jt||Sn|gS(Ni(RR,RZRNRC(RQtlen_arrRR,((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyRCs   (RRRRjRRRtwarningsRRtstructRthashlibRtdecimalRt collectionsR R R t itertoolsR R t six.movesRtsixRRRRRRRRtuuidRtcopyRtcalendarRtdistutils.versionRRRRtjsonRt __author__RRRtobjectR'RFR+RRRRRRRtf_packRRDRURRXRRRRt ihihih_packRtci_packRtbh_packRt cccc_packRRRR4R5R.R/t ExceptionRTRURVRWRXRYRZR[R\R]R^R_R`RaReRiRkRmRnRoRptBINARYRRrRR/R0RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR"RtEXECUTEtFLUSHtSYNCRRt TERMINATER6R-R-RRRR.RtPORTALtRESPONSE_SEVERITYRt RESPONSE_MSGtRESPONSE_DETAILt RESPONSE_HINTtRESPONSE_POSITIONtRESPONSE__POSITIONtRESPONSE__QUERYtRESPONSE_WHEREt RESPONSE_FILEt RESPONSE_LINEtRESPONSE_ROUTINERtIDLE_IN_TRANSACTIONtIDLE_IN_FAILED_TRANSACTIONR>R[RRZR<RJR2RNR<RIRMRERARBRC(((s+/tmp/pip-build-e7KM7X/pg8000/pg8000/core.pyts( :   T                                                                                           ;g