
    ؄_                        d dl mZ d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dlm
Z
 d dlmZ d d	lmZ d d
lmZ d dlmZ  ej        d          d             Z ej        d          d             Zd Z e	j        d          d             Z ej        d          d             Z ej        d          d             Z e
j        d          d             Z ej        d          d             ZdS )   )create_engine)exc)url)configure_follower)	create_db)drop_db)follower_url_from_main)log)run_reap_dbs)temp_table_keyword_args)update_db_optsoraclec                    |                                 5 }|                    d|z             |                    d|z             |                    d|z             |                    d|           |                    d|z             |                    d|z             |                    d|z             d d d            d S # 1 swxY w Y   d S )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_ts2)connectexecutecfgengidentconns       i/var/www/book.euthymeo.com/html/venv/lib/python3.11/site-packages/sqlalchemy/dialects/oracle/provision.py_oracle_create_dbr      s/   
 
 E$6>???:UBCCC:UBCCC%%12227%?@@@;eCDDD;eCDDDE E E E E E E E E E E E E E E E E Es   B)CCCc                 .    d|z  | _         d|z  | _        d S N%s_ts1%s_ts2)test_schematest_schema_2)configr   s     r   _oracle_configure_followerr       s"    !E)F#e+F    c                     	 |                      d|z             t          j        d|           dS # t          j        $ r }t          j        d|           Y d }~dS d }~ww xY w)Nzdrop user %s cascadezReaped db: %sTzcouldn't drop db: %sF)r   r
   infor   DatabaseErrorwarning)r   dbnameerrs      r   _ora_drop_ignorer(   #   sx    +f4555&)))t   *C000uuuuus   -1 A  AA c                     |                                 5 }t          ||           t          |d|z             t          |d|z             d d d            d S # 1 swxY w Y   d S r   )r   r(   r   s       r   _oracle_drop_dbr*   -   s    	 1$ 	u%%%x%/000x%/0001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1s   7AA Ac                     d S )N )db_urldb_optss     r   _oracle_update_db_optsr/   :   s    Dr!   c                    t          j        d|            t          |           }|                                5 }t          j        dd                    |                     |                    d          }d |D             }t                      }|D ]}|                    d          s|                    d          r-||v rS|                    |           d|z  |v r|                    d|z             d	|z  |v r|                    d	|z             d
x}}	t          |d          D ]\  }	}
t          ||
          r|dz  }t          j        d||	           d d d            d S # 1 swxY w Y   d S )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)c                 :    h | ]\  }|                                 S r,   )lower).0usernames     r   	<setcomp>z#_reap_oracle_dbs.<locals>.<setcomp>L   s$    AAA+8X^^%%AAAr!   _ts1_ts2r   r          z-Dropped %d out of %d stale databases detected)r
   r#   r   r   joinr   setendswithadd	enumerater(   )r   identsr   r   to_reap	all_namesto_dropnamedroppedtotalr4   s              r   _reap_oracle_dbsrF   ?   s   H)3///


C	 
$*DIIf,=,=>>>,,8
 

 BAAAA	%% 	1 	1D}}V$$ 1f(=(= 1D!!!d?i//KK4000d?i//KK4000%(!44 	 	OE8h// 1;We	
 	
 	
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s   D$E**E.1E.c                 J    t          j        |           } || _        d| _        | S )Nxe)sa_urlmake_urlr4   password)r   r   s     r   _oracle_follower_url_from_mainrL   a   s$    
/#

CCLCLJr!   c                     dgddS )NzGLOBAL TEMPORARYzPRESERVE ROWS)prefixesoracle_on_commitr,   )r   r   s     r   _oracle_temp_table_keyword_argsrP   i   s     ((+  r!   N) r   r   enginer   rI   testing.provisionr   r   r   r	   r
   r   r   r   for_dbr   r    r(   r*   r/   rF   rL   rP   r,   r!   r   <module>rU      s	               # # # # # # 3 3 3 3 3 3 * * * * * * ( ( ( ( ( ( 7 7 7 7 7 7 $ $ $ $ $ $ - - - - - - 8 8 8 8 8 8 / / / / / / (E E E 8$$, , %$,
   	1 	1 	1 x  	 	 ! 	 X
 
 
B x((  )(  ))  *)  r!   