
    h+                        S SK r S SKrS SKrS SKrS SKrS SKrS SKJr  S SKJ	r	  S SK
Jr  S SKJr  S SKJr  \R                   " S5      r " S S	5      r " S
 S\5      r\S 5       rS rS rS rS rS rSS jrS rS rS rg)    N)contextmanager)md5)apps)NotSupportedError)
parse_timezdjango.db.backendsc                   v    \ rS rSrS r\" / SQ5      rSrS rS r	S r
S rSS
 jrSS jrS rS rS rS rSrg	)CursorWrapper   c                     Xl         X l        g Ncursordb)selfr   r   s      J/var/www/html/env/lib/python3.13/site-packages/django/db/backends/utils.py__init__CursorWrapper.__init__   s        )fetchone	fetchmanyfetchallnextsetzAccessing the database during app initialization is discouraged. To fix this warning, avoid executing queries in AppConfig.ready() or when your app modules are imported.c                     [        U R                  U5      nU[        R                  ;   a  U R                  R                  U5      $ U$ r   )getattrr   r	   WRAP_ERROR_ATTRSr   wrap_database_errors)r   attrcursor_attrs      r   __getattr__CursorWrapper.__getattr__   s;    dkk40=11177//<<r   c              #      #    U R                   R                     U R                   S h  vN   S S S 5        g  N! , (       d  f       g = f7fr   )r   r   r   r   s    r   __iter__CursorWrapper.__iter__%   s2     WW)){{"" *)" *)s%   A
979	A
9
AA
c                     U $ r    r"   s    r   	__enter__CursorWrapper.__enter__)   s    r   c                 z     U R                  5         g ! U R                  R                  R                   a     g f = fr   )closer   DatabaseError)r   typevalue	tracebacks       r   __exit__CursorWrapper.__exit__,   s2    	JJLww%% 		s    $::Nc                    Ub0  U R                   R                  R                  (       d  [        S5      e[        R
                  (       d8  [        R                  (       d#  [        R                  " U R                  [        S9  U R                   R                  5         U R                   R                     Uc'  Uc$  U R                  R                  U5      sS S S 5        $ Uc$  U R                  R                  X5      sS S S 5        $ U=(       d    SnU R                  R                  XU5      sS S S 5        $ ! , (       d  f       g = f)NzKKeyword parameters for callproc are not supported on this database backend.categoryr&   )r   featuressupports_callproc_kwargsr   r   readystored_app_configswarningswarnAPPS_NOT_READY_WARNING_MSGRuntimeWarningvalidate_no_broken_transactionr   r   callproc)r   procnameparamskparamss       r   r>   CursorWrapper.callproc8   s     tww'7'7'P'P#$  zz$"9"9MM$99NS..0WW))~'/{{++H5 *) {{++H=	 *)  2{{++HgF *))s   1!D3D3&D33
Ec                 8    U R                  XSU R                  S9$ )NFmanyexecutor)_execute_with_wrappers_execute)r   sqlr@   s      r   executeCursorWrapper.executeN   s%    **edmm + 
 	
r   c                 8    U R                  XSU R                  S9$ )NTrD   )rG   _executemany)r   rI   
param_lists      r   executemanyCursorWrapper.executemanyS   s'    **$1B1B + 
 	
r   c                     U R                   U S.n[        U R                   R                  5       H  n[        R                  " Xd5      nM     U" XX55      $ )N)
connectionr   )r   reversedexecute_wrappers	functoolspartial)r   rI   r@   rE   rF   contextwrappers          r   rG   $CursorWrapper._execute_with_wrappersX   sF    !%D9 8 89G ((;H :T33r   c                    [         R                  (       d8  [         R                  (       d#  [        R                  " U R
                  [        S9  U R                  R                  5         U R                  R                     Uc$  U R                  R                  U5      sS S S 5        $ U R                  R                  X5      sS S S 5        $ ! , (       d  f       g = fNr3   )r   r7   r8   r9   r:   r;   r<   r   r=   r   r   rJ   )r   rI   r@   ignored_wrapper_argss       r   rH   CursorWrapper._execute^   s     zz$"9"9MM$99NS..0WW))~{{**3/ *)
 {{**37 *))s   >C
&C


Cc                 h   [         R                  (       d8  [         R                  (       d#  [        R                  " U R
                  [        S9  U R                  R                  5         U R                  R                     U R                  R                  X5      sS S S 5        $ ! , (       d  f       g = fr[   )r   r7   r8   r9   r:   r;   r<   r   r=   r   r   rO   )r   rI   rN   r\   s       r   rM   CursorWrapper._executemanyk   sb     zz$"9"9MM$99NS..0WW));;**3; *))s   >B##
B1r   )NNr   )__name__
__module____qualname____firstlineno__r   	frozensetr   r;   r   r#   r'   r0   r>   rJ   rO   rG   rH   rM   __static_attributes__r&   r   r   r	   r	      sR     !!QR	  #G,



48<r   r	   c                   N   ^  \ rS rSrSU 4S jjrU 4S jr\ SS j5       rSrU =r	$ )CursorDebugWrapperu   c                 x   > U R                  XSS9   [        TU ]	  X5      sS S S 5        $ ! , (       d  f       g = f)NT)use_last_executed_query)	debug_sqlsuperrJ   )r   rI   r@   	__class__s      r   rJ   CursorDebugWrapper.executex   s,    ^^C^F7?3/ GFF   +
9c                 x   > U R                  XSS9   [        TU ]	  X5      sS S S 5        $ ! , (       d  f       g = f)NT)rE   )rk   rl   rO   )r   rI   rN   rm   s      r   rO   CursorDebugWrapper.executemany|   s,    ^^C$^77&s7 877ro   c              #   (  #    [         R                  " 5       n S v   [         R                  " 5       nXe-
  nU(       a0  U R                  R                  R	                  U R
                  X5      n U(       a  [        U5      OSnU R                  R                  R                  U(       a	  U< SU< 3OUSU-  S.5        [        R                  SUUUU R                  R                  UUUU R                  R                  S.S9  g ! [         a    Sn Nf = f! [         R                  " 5       nXe-
  nU(       a0  U R                  R                  R	                  U R
                  X5      n U(       a  [        U5      OSnO! [         a    Sn Of = fU R                  R                  R                  U(       a	  U< SU< 3OUSU-  S.5        [        R                  SUUUU R                  R                  UUUU R                  R                  S.S9  f = f7f)	N ?z times: %.3frI   time(%.3f) %s; args=%s; alias=%s)durationrI   r@   aliasextra)rw   	monotonicr   opslast_executed_queryr   len	TypeErrorqueries_logappendloggerdebugrz   )	r   rI   r@   rj   rE   startstopry   timess	            r   rk   CursorDebugWrapper.debug_sql   s      	>>#D|H&ggkk55dkk3O'+F GG&&<@UC8c"X- LL. ($!WW]]	     >>#D|H&ggkk55dkk3O'+F  GG&&<@UC8c"X- LL. ($!WW]]	  sg   HD AH.D BHDHDHAH'E<;H<FH
FBHHr&   r   )NNFF)
r`   ra   rb   rc   rJ   rO   r   rk   re   __classcell__)rm   s   @r   rg   rg   u   s$    08 IN" "r   rg   c              #   F  #    [         R                  " 5       n S v   U R                  (       an  [         R                  " 5       nX2-
  nU R                  R	                  SU-  SU-  S.5        [
        R                  SUUS U R                  UUU R                  S.S9  g g ! U R                  (       an  [         R                  " 5       nX2-
  nU R                  R	                  SU-  SU-  S.5        [
        R                  SUUS U R                  UUU R                  S.S9  f f = f7f)Nz%sru   rv   rx   )ry   rI   rz   r{   )rw   r}   queries_loggedr   r   r   r   rz   )rR   rI   r   r   ry   s        r   debug_transactionr      s#    NNE$$>>#D|H""))#:"X- LL.   ('--   %:$$>>#D|H""))#:"X- LL.   ('--   %s   D!B B D!BDD!c                     S HH  nX;   d  M
  U R                  US5      u  p#U(       d  M'  [        U5      (       d  M9  SU;  a  U S3nX!U4s  $    U SS4$ )z@
Split a time zone name into a 3-tuple of (name, sign, offset).
)+-   :z:00N)rsplitr   )tznamesignnameoffsets       r   split_tzname_deltar      sa     >!==q1LDv*V,,f$ &xs^F6))  4r   c                 t    U (       a0  [         R                  " [        [        U R	                  S5      5      6 $ S $ )Nr   )datetimedatemapintsplit)ss    r   typecast_dater      s,    23s3-.9=r   c           
          U (       d  g U R                  S5      u  pnSU;   a  UR                  S5      u  p4OSn[        R                  " [        U5      [        U5      [        U5      [        US-   S S 5      5      $ )Nr   .0000000   )r   r   rw   r   )r   hourminutessecondsmicrosecondss        r   typecast_timer      sp    WWS\D7
g~ 'c 2==D	3w<WsL84KRa3P/Q r   c                 (   U (       d  g SU ;  a  [        U 5      $ U R                  5       u  pSU;   a  UR                  SS5      u  p#OSU;   a  UR                  SS5      u  p#UR                  S5      nUR                  S5      nUS   nSU;   a  UR                  S5      u  pgOSn[        R                  " [        US	   5      [        US   5      [        US   5      [        US	   5      [        US   5      [        U5      [        US
-   S S 5      5      $ )N r   r   r   r      r   r   r   r   r   )r   r   r   r   )r   dt_datesr   r   r   s           r   typecast_timestampr      s    
!|Q779DA
axwwsA1	wwsAGGCLEGGCLEAhG
g~ 'c 2E!HE!HE!HE!HE!HG\H$bq)* r   c                      U R                  S5      u  pUR                  S5      UR                  S5      4$ ! [         a    SU p! N1f = f)z
Split an SQL identifier into a two element tuple of (namespace, name).

The identifier could be a table, column, or sequence name might be prefixed
by a namespace.
z"."rs   ")r   
ValueErrorstrip)
identifier	namespacer   s      r   split_identifierr     sO    )$**51	 ??3C00  )j4)s   7 AAc                     [        U 5      u  p4Ub  [        U5      U::  a  U $ [        XBS9nU(       a  SU-  OS< USX-
   < U< 3$ )z
Shorten an SQL identifier to a repeatable mangled version with the given
length.

If a quote stripped name contains a namespace, e.g. USERNAME"."TABLE,
truncate the table portion only.
N)lengthz%s"."rs   )r   r   names_digest)r   r   hash_lenr   r   digests         r   truncate_namer     sZ     'z2OI~Tf,$0F()b0 v ! r   c                     [        SS9nU H"  nUR                  UR                  5       5        M$     UR                  5       SU  $ )z_
Generate a 32-bit digest of a set of arguments that can be used to shorten
identifying names.
F)usedforsecurityN)r   updateencode	hexdigest)r   argshargs       r   r   r   0  s=    
 	E"A	 ;;=&!!r   c                 P   U c  g[         R                  " 5       R                  5       nUb  Xl        Ub5  U R	                  [         R
                  " S5      R                  U* 5      US9n O.SUR                  [         R                  '   UR                  U 5      n SR                  U 5      $ )zW
Format a number into a string with the requisite number of digits and
decimal places.
Nr   )rW   z{:f})decimal
getcontextcopyprecquantizeDecimalscalebtrapsRoundedcreate_decimalformat)r.   
max_digitsdecimal_placesrW   s       r   format_numberr   ;  s    
 }  "'')G!!OOA%%~o6  
 *+goo&&&u-==r   c                 p    U R                  S5      =(       a    U R                  S5      nU(       a  U SS $ U $ )z
Strip quotes off of quoted table names to make them safe for use in index
names, sequence names, etc. For example '"USER"."TABLE"' (an Oracle naming
scheme) becomes 'USER"."TABLE'.
r   r   )
startswithendswith)
table_name
has_quotess     r   strip_quotesr   O  s8     &&s+H
0C0CC0HJ):a9z9r   )N   )r   r   rU   loggingrw   r9   
contextlibr   hashlibr   django.appsr   	django.dbr   django.utils.dateparser   	getLoggerr   r	   rg   r   r   r   r   r   r   r   r   r   r   r&   r   r   <module>r      s          %   ' -			/	0a< a<H. .b  8&
H1*" (:r   