
    df                     v    d dl mZ d dlmZ d dlmZ d dlmZmZ d dl	m
Z
mZmZmZmZmZ  G d de          ZdS )	    )settings)caches)BaseDatabaseCache)BaseCommandCommandError)DEFAULT_DB_ALIASDatabaseErrorconnectionsmodelsroutertransactionc                   (    e Zd ZdZg Zd Zd Zd ZdS )Commandz7Creates the tables needed to use the SQL cache backend.c                     |                     dddd           |                     dt          d           |                     d	d
d           d S )Nargs
table_name*zNOptional table names. Otherwise, settings.CACHES is used to find cache tables.)metavarnargshelpz
--databasezgNominates a database onto which the cache tables will be installed. Defaults to the "default" database.)defaultr   z	--dry-run
store_truezADoes not create the table, just prints the SQL that would be run.)actionr   )add_argumentr   )selfparsers     lD:\Python Project\djangoTemplates\venv\Lib\site-packages\django/core/management/commands/createcachetable.pyadd_argumentszCommand.add_arguments   s       	 	
 	
 	
 	$= 	 	
 	
 	
 	T 	 	
 	
 	
 	
 	
    c                    |d         }|d         | _         |d         }|r|D ]}|                     |||           d S t          j        D ]@}t          |         }t          |t                    r|                     ||j        |           Ad S )Ndatabase	verbositydry_run)r"   create_tabler   CACHESr   
isinstancer   _table)r   
tablenamesoptionsdbr#   	tablenamecache_aliascaches           r   handlezCommand.handle*   s    Z  -)$ 	A' : :	!!"i9999: :  ( A A{+e%677 A%%b%,@@@A Ar   c                    t          |i           }t          j        ||j                  sd S t          |         }||j                                        v r*| j        dk    r| j        	                    d|z             d S t          j        dddd          t          j        d          t          j        d	d
          f}g }g }|j        j        }	|D ]}
 |	|
j                  |
                    |          d|
j        sdndz  g}|
j        r|                    d           n|
j        r|                    d           |
j        rW|
j        rdnd}|                    d|d |	|d|
j                  d |	|          d |	|
j                  d	           |                    d                    |                     d |	|          z  g}t1          |          D ]7\  }}|                    d||t3          |          dz
  k     rdnd           8|                    d           d                    |          }|r;| j        	                    |           |D ]}| j        	                    |           d S t5          j        ||j        j                  5  |                                5 }	 |                    |           n(# t@          $ r}tC          d|d |d!          d }~ww xY w|D ]}|                    |           	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   | j        dk    r| j        	                    d"|z             d S d S )#Nr   z Cache table '%s' already exists.	cache_key   T)name
max_lengthuniqueprimary_keyvalue)r2   expires)r2   db_index)
connectionz%sNULLzNOT  zPRIMARY KEYUNIQUEzUNIQUE zCREATE zINDEX _z ON z (z); zCREATE TABLE %s (z       ,
)using	savepointzCache table 'z'' could not be created.
The error was: .zCache table '%s' created.)"r   r   allow_migrate_modelcache_model_classr
   introspectiontable_namesr"   stdoutwriter   	CharField	TextFieldDateTimeFieldops
quote_namer2   db_typenullr5   appendr4   r8   join	enumeratelenr   atomicfeaturescan_rollback_ddlcursorexecuter	   r   )r   r!   r+   r#   r-   r9   fieldstable_outputindex_outputqnffield_outputr4   full_statementiline	statementcurses                      r   r$   zCommand.create_table8   s   !)R00)(E4KLL 	F *

0<<>>>>~!!!!"Dy"PQQQF  S4   '*** i$???
 ^& 	8 	8A16

		Z	00!&8FFb9L
 } .##M2222 .##H---z 
&'h6B### iii89999916



    6 67777-9=> .. 	 	GAt!!!"d1s</@/@1/D+D+DCC"$LM    	d###>22 	Kn---) - -	!!),,,,Fj&9&J
 
 
 	, 	, ""$$ 	,LL0000$   &,$99aaa)  
 ". , ,ILL++++,	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, >AK9IEFFFFF sZ   %L8:L!<KL!
K7K22K77L!L8!L%	%L8(L%	)L88L<?L<N)__name__
__module____qualname__r   requires_system_checksr   r.   r$    r   r   r   r      sY        DD
 
 
,A A AJG JG JG JG JGr   r   N)django.confr   django.core.cacher   django.core.cache.backends.dbr   django.core.management.baser   r   	django.dbr   r	   r
   r   r   r   r   rj   r   r   <module>rp      s                $ $ $ $ $ $ ; ; ; ; ; ; A A A A A A A A               sG sG sG sG sGk sG sG sG sG sGr   