
    Dh                         d dl Z e j                  dk\  rd dlmZ nd dlmZ d dlmZ d dlmZ 	 d dl	Z	dZ
 G d d	e      Zy# e$ r dZ
Y w xY w)
    N      )BaseDatabaseFeatures)cached_property)sixTFc                   
    e Zd ZdZg 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ZdZdZdZdZdZdZdZej4                  dk  rdZej:                  ZdZ fdZ e!d        Z"e!d        Z#e!d        Z$e!d	        Z%e!d
        Z&d Z' xZ(S )DatabaseFeatureszFeatures specific to MySQL

    Microsecond precision is supported since MySQL 5.6.3 and turned on
    by default if this MySQL version is used.
    FTr   c                 ,    t         t        |   |       y )N)superr
   __init__)self
connection	__class__s     _/var/www/html/civilisation/venv/lib/python3.12/site-packages/mysql/connector/django/features.pyr   zDatabaseFeatures.__init__5   s    .z:    c                 8    | j                   j                  dk\  ryy)N)         TF)r   mysql_versionr   s    r   supports_microsecond_precisionz/DatabaseFeatures.supports_microsecond_precision8   s    ??((I5r   c                 8   d}dj                  |      }| j                  j                         5 }|j                  |       |j                  dj                  |             | j                  j                  dk\  r?|j                  d| j                  j
                  d   |f       |j                         d   }n4|j                  d	j                  |             |j                         d
   }|j                  |       ddd       | _        |S # 1 sw Y   xY w)zGet default storage engine of MySQL

        This method creates a table without ENGINE table option and inspects
        which engine was used.

        Used by Django tests.
        INTROSPECT_TESTzDROP TABLE IF EXISTS {table})tablezCREATE TABLE {table} (X INT))r   r   r   zXSELECT ENGINE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = %s AND TABLE_NAME = %sNAMEr   z&SHOW TABLE STATUS WHERE Name='{table}'r   N)formatr   cursorexecuter   settings_dictfetchone_cached_storage_engine)r   tblname	droptabler   engines        r   mysql_storage_enginez%DatabaseFeatures.mysql_storage_engine>   s
    $2999H	__##% 	&NN9%NN9@@w@OP,,	9B__226:GDF  *1- GNN!  O  # $*1-NN9%	&" '-#%	& 	&s   CDDc                      | j                   dk(  S )NInnoDBr'   r   s    r   _disabled_supports_transactionsz0DatabaseFeatures._disabled_supports_transactions^   s    ((H44r   c                      | j                   dk(  S )zConfirm support for introspected foreign keys

        Only the InnoDB storage engine supports Foreigen Key (not taking
        into account MySQL Cluster here).
        r)   r*   r   s    r   can_introspect_foreign_keysz,DatabaseFeatures.can_introspect_foreign_keysb   s     ((H44r   c                     t         sy| j                  j                         5 }|j                  d       |j	                         g k7  cddd       S # 1 sw Y   yxY w)a  Tests if the time zone definitions are installed

        MySQL accepts full time zones names (eg. Africa/Nairobi) but rejects
        abbreviations (eg. EAT). When pytz isn't installed and the current
        time zone is LocalTimezone (the only sensible value in this context),
        the current time zone name will be an abbreviation. As a consequence,
        MySQL cannot perform time zone conversions reliably.
        Fz%SELECT 1 FROM mysql.time_zone LIMIT 1N)	HAVE_PYTZr   r   r    fetchall)r   r   s     r   has_zoneinfo_databasez&DatabaseFeatures.has_zoneinfo_databasek   sM     __##% 	+NNBC??$*	+ 	+ 	+s   $AAc                      y)NIntegerField )r   argskwargss      r   introspected_boolean_field_typez0DatabaseFeatures.introspected_boolean_field_type}   s    r   ))__name__
__module____qualname____doc__empty_fetchmany_valueupdate_can_self_selectallows_group_by_pkrelated_fields_match_typeallow_sliced_subquerieshas_bulk_inserthas_select_for_updatehas_select_for_update_nowaitsupports_forward_referencessupports_regex_backreferencing!supports_date_lookup_using_stringcan_introspect_autofieldcan_introspect_binary_field"can_introspect_small_integer_fieldsupports_timezones-requires_explicit_null_ordering_when_groupingallows_auto_pk_0allows_primary_key_0uses_savepointsatomic_transactions!supports_column_check_constraintsdjangoVERSIONsupports_long_model_namesr   PY2supports_binary_fieldcan_introspect_boolean_fieldr   r   r   r'   r+   r-   r1   r7   __classcell__)r   s   @r   r
   r
      s   
 " $#O #( "'%*"(-%#"')-&481 O(-%~~$)! #',$;  
  > 5 5 5 5 + +"r   r
   )rQ   rR    django.db.backends.base.featuresr   django.db.backendsdjango.utils.functionalr   django.utilsr   pytzr/   ImportErrorr
   r4   r   r   <module>r^      sT   
 	>>VE7 3 I
k+ k	  Is   A   A
	A
