
    Ki+                        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	  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  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  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  SSKJr  \R6                  " S5      S 5       r\
R6                  " S5      S 5       r\	R6                  " S5      S 5       rS r\R6                  " S5      S 5       r \R6                  " S5      S 5       r!\R6                  " S5      S 5       r"\R6                  " S5      S  5       r#S+S! jr$\R6                  " S5      S" 5       r%S# r&\R6                  " S5      S$ 5       r'\R6                  " S5      S% 5       r(\R6                  " S5      S& 5       r)\R6                  " S5      S' 5       r*\R6                  " S5      S( 5       r+\R6                  " S5      S) 5       r,\R6                  " S5      S* 5       r-g),    N   )create_engine)exc)inspect)url)configure_follower)	create_db)#drop_all_schema_objects_post_tables)"drop_all_schema_objects_pre_tables)drop_db)follower_url_from_main)generate_driver_url)is_preferred_driver)log)post_configure_engine)post_configure_testing_engine)run_reap_dbs) set_default_schema_on_connection) stop_test_class_outside_fixtures)temp_table_keyword_args)update_db_opts)warn_test_suiteoraclec                    U R                  5       nU R                  U< SU< 3S9nUS;   a  UR                  SS/5      nOUR                  SS/5      n UR	                  5         U$ ! [
        R                   a     g f = f)N+)
drivername)oracledboracledb_async)retry_count5)retry_delay2r   r!   )get_backend_namesetupdate_query_pairsdifference_update_queryget_dialectr   NoSuchModuleError)r   driver	query_strbackendnew_urls        f/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/sqlalchemy/dialects/oracle/provision.py_oracle_generate_driver_urlr.   "   s     ""$Ggg%v.  G // ,,!#78
 11M*
     s   A' 'A>=A>c                    UR                  5        nUR                  SU-  5        UR                  SU-  5        UR                  SU-  5        UR                  SU< 35        UR                  SU-  5        UR                  SU-  5        UR                  SU-  5        UR                  SU-  5        UR                  S	U-  5        UR                  S
U-  5        S S S 5        g ! , (       d  f       g = f)Nzcreate user %s identified by xez#create user %s_ts1 identified by xez#create user %s_ts2 identified by xezgrant dba to z grant unlimited tablespace to %sz$grant unlimited tablespace to %s_ts1z$grant unlimited tablespace to %s_ts2zgrant create table to %szgrant create table to %s_ts1zgrant create table to %s_ts2)beginexec_driver_sqlcfgengidentconns       r-   _oracle_create_dbr7   C   s    
 
>FGBUJKBUJK%9:?%GHCeKLCeKL7%?@;eCD;eCD 
s   C
C$$
C2c                 ,    SU-  U l         SU-  U l        g N%s_ts1%s_ts2)test_schematest_schema_2)configr5   s     r-   _oracle_configure_followerr?   V   s    !E)F#e+F    c                      U R                  SU-  5        [        R                  " SU5        g! [        R                   a!  n[        R
                  " SU5         S nAgS nAff = f)Nzdrop user %s cascadezReaped db: %sTzcouldn't drop db: %sF)r1   r   infor   DatabaseErrorwarning)r6   dbnameerrs      r-   _ora_drop_ignorerG   \   sT    3f<=&) *C0s   +. A#AA#c                 D    [        U5        [        XR                  5        g N)_purge_recyclebinr<   r3   r4   s     r-   '_ora_drop_all_schema_objects_pre_tablesrL   f   s    cc??+r@   c           	         UR                  5        nUR                  R                  US S S 5       H  nUR                  SUS    35        M     UR                  R                  X R                  S S 5       H'  nUR                  SU R                   SUS    35        M)     [        U5      R                  5        H  nUR                  SU 35        M     S S S 5        g ! , (       d  f       g = f)Nzdrop synonym synonym_name.zdrop table )r0   dialect_get_synonymsr1   r<   r   get_temp_table_names)r3   r4   r6   syn	tmp_tables        r-   (_ora_drop_all_schema_objects_post_tablesrU   l   s    	<<--dD$EC  =^1D0E!FG F <<--//4
C   0#n2E1FG
 !;;=I  ;yk!:; > 
s   CC
C+c                     UR                  5        n[        X25        [        USU-  5        [        USU-  5        S S S 5        g ! , (       d  f       g = fr9   )r0   rG   r2   s       r-   _oracle_drop_dbrW   }   s?    	 	%x%/0x%/0 
s   *A
Ac                      [        U5        g ! [        R                   a!  n[        R                  " SU5         S nAg S nAff = f)Nz#purge recyclebin command failed: %s)rJ   r   rC   r   rD   )r>   dbclsrF   s       r-   %_ora_stop_test_class_outside_fixturesr[      s:    @" @93??@s    A>Ac                 B   U R                  5        nUc  UR                  S5        O`UR                  SSUR                  R                  U5      05      R	                  5        H!  u  p4nUR                  SU SU SU S35        M#     S S S 5        g ! , (       d  f       g = f)Nzpurge recyclebinzWselect owner, object_name,type from dba_recyclebin where owner=:schema and type='TABLE'schemazpurge  z."")r0   r1   rP   denormalize_nameall)r4   r]   r6   ownerobject_nametype_s         r-   rJ   rJ      s    	>   !34 .2-A-AF4<<88@A. ce	.)E
 $$veWAeWB{m1%MN. 
s   A6B
Bc                 x    UR                   R                  S:H  =(       a    UR                   R                  (       + $ )zpestablish oracledb as the preferred driver to use for tests, even
though cx_Oracle is still the "default" driverr   )rP   r)   is_async)r3   engines     r-   _oracle_is_preferred_driverrh      s+    
 >>  J.Nv~~7N7N3NNr@   c                    U R                   S:X  d   eS nS n[        S5       H   n U R                  R                  " U0 UD6s  $    Ub  [        S5      Ueg ! U R                  R                  U R                  R
                  4 a<  nUnU" U5      (       a'  [        S5        [        R                  " S5         S nAM  e S nAff = f)N	cx_oraclec                 H    S[        U 5      ;   =(       d    S[        U 5      ;   $ )NzDPY-6005z	ORA-12516)str)rF   s    r-   _is_couldnt_connect0_connect_with_retry.<locals>._is_couldnt_connect   s    SX%@C)@@r@      zOracle database reconnecting...   z"connect failed after five attempts)
r)   rangeloaded_dbapiconnectrC   OperationalErrorr   timesleep	Exception)rP   conn_reccargscparamsrm   err__rF   s           r-   _connect_with_retryr}      s    >>[(((A D1X	''//B'BB  <=4G    ..  11
 
	 D"3'' AB

1
	s   A0C0B>=B>>Cc                 t    SSK Jn  UR                  R                  S:X  a  UR	                  US[
        5        g g )Nr   eventrj   
do_connect) r   rP   r)   listenr}   )r   rg   optionsscoper   s        r-   %_oracle_post_configure_testing_enginer      s-    ~~+V\+>? ,r@   c                 @    SSK Jn  UR                  US5      S 5       ng )Nr   r   checkinc                 F     U R                   nSU l         X l         g !    g = f)Nr   )stmtcachesize)dbapi_connectionconnection_recordscs      r-   r   ._oracle_post_configure_engine.<locals>.checkin   s-     	0!//B
 ./*-/*	s     )r   r   listens_for)r   rg   follower_identr   r   s        r-   _oracle_post_configure_enginer      s&     
vy)0 *0r@   c                    [         R                  " SU 5        [        U 5      nUR                  5        n[         R                  " SSR	                  U5      5        UR                  S5      nU Vs1 s H  u  oUR                  5       iM     nn[        5       nU H  nUR                  S5      (       d  UR                  S5      (       a  M1  X;   d  M8  UR                  U5        SU-  U;   a  UR                  SU-  5        SU-  U;   d  Mq  UR                  SU-  5        M     S	=p[        US
5       H  u  p[        X55      (       d  M  U	S
-  n	M     [         R                  " SX5        S S S 5        g s  snf ! , (       d  f       g = f)Nzdb reaper connecting to %rzidentifiers in file: %sz, zselect u.username from all_users u where username like 'TEST_%' and not exists (select username from v$session where username=u.username)_ts1_ts2r:   r;   r      z-Dropped %d out of %d stale databases detected)r   rB   r   r0   joinr1   lowerr$   endswithadd	enumeraterG   )r   identsr4   r6   to_reapusername	all_namesto_dropnamedroppedtotals              r-   _reap_oracle_dbsr      sD   HH)3/

C	*DIIf,=>&&8

 :AA+8^^%	A%D}}V$$f(=(=D!d?i/KK40d?i/KK40  (!4OE//1  5 	;W	
1 
 B 
s0   <E5/E0
AE55E5	:E5 E50E55
Fc                 N    [         R                  " U 5      n U R                  USS9$ )Nxe)r   password)sa_urlmake_urlr$   )r   r5   s     r-   _oracle_follower_url_from_mainr     s#    
//#
C77ED711r@   c                     S/SS.$ )NzGLOBAL TEMPORARYzPRESERVE ROWS)prefixesoracle_on_commit rK   s     r-   _oracle_temp_table_keyword_argsr     s     ((+ r@   c                 l    UR                  5       nUR                  SU-  5        UR                  5         g )Nz#ALTER SESSION SET CURRENT_SCHEMA=%s)cursorexecuteclose)r3   r   schema_namer   s       r-   (_oracle_set_default_schema_on_connectionr     s-     $$&F
NN8;FG
LLNr@   c                     UR                   (       a/  [        R                  " U 5      R                  5       S:X  a  SUS'   ggg)zCSet database options (db_opts) for a test database that we created.r   T
thick_modeN)oracledb_thick_moder   r   get_driver_name)db_urldb_optsr   s      r-   _update_db_optsr   "  s<     	##OOF#335C $ D 	$r@   rI   ).ru   r   r   r   r   rg   r   r   testing.provisionr   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   testing.warningsr   for_dbr.   r7   r?   rG   rL   rU   rW   r[   rJ   rh   r}   r   r   r   r   r   r   r   r   r@   r-   <module>r      s3       # 3 * D C ( 7 4 4 $ 6 > - A A 8 / / H% &@ (E E$ 8$, %,
 $**84, 5,
 %++H5< 6<  		1 	1 "((2@ 3@O  H%O &OH2 %%h/@ 0@ h'0 (0< X
 
@ x(2 )2
 ) * "((2 3 x % !%r@   