+
    Ki  c                   s    ^ RI t ^ RIt^ RIHt ]P                  ! 4       t ! R R]4      tRR ltR t	R t
R tRR	 ltRR
 ltR tRR R lltRR ltR# )    N)Anyc                   s2   a  ] tR t^	t o R tR tR tRtV tR# )	db_cursorc                s     Wn         R V n        R # N)db_pathdb_conn)selfr   s   &&8/usr/lib/python3.14/site-packages/lutris/database/sql.py__init__Zdb_cursor.__init__
   s        c                s    \         P                  ! V P                  4      V n        V P                  P	                  4       pV# r   )sqlite3Zconnectr   r   cursor)r   r   s   & r   	__enter__Zdb_cursor.__enter__   s-    t||4$$&r	   c                sn    V P                   P                  4        V P                   P                  4        R # r   )r   ZcommitZclose)r   Z_typevalueZ	tracebacks   &&&&r   __exit__Zdb_cursor.__exit__   s"    r	   )r   r   N)	Z__name__Z
__module__Z__qualname__Z__firstlineno__r   r   r   Z__static_attributes__Z__classdictcell__)Z__classdict__s   @r   r   r   	   s     
 r	   r   c                s    T;'       g    Rp\         P                  ^R7      pV'       g   \        RV 24      h V P                  W4      \         P	                  4        #   \         P	                  4        i ; i)z+Execute a SQL query, run it in a lock block)Ztimeoutz Database is busy. Not executing  )DB_LOCKZacquireZRuntimeErrorexecuteZrelease)r   queryparamsZlocks   &&& r   cursor_executer      sY    \\rF??1?%D=eWEFF~~e,s   A A5c           
      sd   R P                  \        VP                  4       4      4      pR\        V4      ,          RR p\	        VP                  4       4      p\        V 4      ;_uu_ 4       p\        VRP                  WV4      V4       VP                  pRRR4       V#   + '       g   i     X# ; i), z?, Nz!insert into {0}({1}) values ({2})i)
joinlistkeyslentuplevaluesr   r   formatZ	lastrowid)r   tablefieldscolumnsplaceholdersfield_valuesr   Zinserted_ids   &&&     r   	db_insertr"   %   s    iiV[[]+,GCK'"-L)L	7		v/66u|T	

 && 
  
	 s   **BB/	c                s   RP                  \        VP                  4       4      4      R,           p\        VP	                  4       4      pRP                  V Uu. uF  pRV,          NK  	  up4      p\        VP	                  4       4      p\        V 4      ;_uu_ 4       p	RP                  WV4      p
\        WWX,           4      pRRR4       V# u upi   + '       g   i     X# ; i)zgUpdate `table` with the values given in the dict `values` on the
condition given with the `row` tuple.
z=?, z=? AND z%s=?zUPDATE {0} SET {1} WHERE {2}N)r   r   r   r   r   r   r   r   )r   r   Zupdated_fieldsZ
conditionsr   r!   fieldcondition_fieldcondition_valuer   r   Zresults   &&&&        r   	db_updater'   3   s     kk$~22456=G..01Lll
#K
uFUNN
#KLOJ--/0O	7		v.55eoV|/MN 
 M $L 
	 Ms   C%CC"	c           	      s    \        V 4      ;_uu_ 4       p\        VR P                  W4      V34       RRR4       R#   + '       g   i     R# ; i)zdelete from {0} where {1}=?N)r   r   r   )r   r   r$   r   r   s   &&&& r   	db_deleter(   C   s:    	7		vv<CCEQTYS[\ 
			s	   <A	c                 s   V'       d   R P                  V4      pMRp\        V 4      ;_uu_ 4       pRpV'       d   Vw  rx\        V\        \        \
        34      '       d>   \	        V4      pR P                  R\        V4      ,          4      p	RV	,           R,           p
MV3pRp
Wj,           pVP                  WAV4      pTpMVP                  WA4      pRp\        WVV4       VP                  4       pVP                   Uu. uF  q^ ,          NK  	  ppRRR4       . pX F7  p/ p\        X4       F  w  ppVV,          VV&   K  	  VP                  V4       K9  	  V# u upi   + '       g   i     LV; i)	r   Z*zSELECT {} FROM {}?z where {} in ()z where {}=?Nr   )r   r   
isinstancer   r   Zsetr   r   r   fetchalldescription	enumerateappend)r   r   r   Z	conditionr   r   r   r%   r&   r    Zwhere_conditionr   rowscolumncolumn_namesresultsrowrow_dataindexs   &&&&               r   	db_selectr7   H   sK   ))F#	7		v#/8,O/D%+=>>"'"8#yys?/C)CD"2\"AC"G#2"4"/+ELLAE$FLL0EFvf- 060B0BC0Bfq		0BC' 
( G&|4ME6"5zHV 5x 	 
 N D' 
	s   CE<EEEE-	c                 s`   \        V 4      ;_uu_ 4       p\        W1V4       VP                  4       pVP                   Uu. uF  qU^ ,          NK  	  ppRRR4       . pX F4  p/ p	\	        X4       F  w  rW,          W&   K  	  VP                  V	4       K6  	  V# u upi   + '       g   i     LS; i)r    N)r   r   r,   r-   r.   r/   )r   r   r   r   r0   r1   r2   r3   r4   r5   r6   s   &&&        r   db_queryr8   j   s    	7		vvf- 060B0BC0Bfq		0BC 
 G&|4ME"zH 5x 	 
 N D 
	s   +BBBBB-	c                 s    R V: RVR,          : RVR,          : 2p\        V 4      ;_uu_ 4       pVP                  V4       RRR4       R#   + '       g   i     R# ; i)zALTER TABLE z ADD COLUMN Zname ZtypeN)r   r   )r   Z	tablenamer$   r   r   s   &&&  r   	add_fieldr:   x   sF    ffE
 
7		vu 
			s   AA	c          
      sT    V ^8  d   QhR\         R\        R\        R\        R\         /# )i   r$   r   r   negateZreturn)strr   r   Zbool)r   s   "r   __annotate__r=      s0     . .# .c .4 . .RU .r	   c                s   Rp\        VR4      '       d=   \        V\        4      '       g'   \        V4      pRV9   d   VP	                  R4       RpMVf   Rp. pMV.p\        V4      ^ 8X  d'   V'       d   V'       d   V  R2# R# V'       d   V  R2# R# \        V4      ^8X  d,   VP                  V^ ,          4       V'       d   V  R	2MV  R
2pMYV'       d   V  R2MV  R2p\        V4       F/  w  rxVP                  V4       V^ 8  d
   VR,          pVR,          pK1  	  VR,          pV'       d   V'       d
   RV  RV R2# RV  RV R2# V# )zmCreates a filter to match a field to a vlaue, or to a list of
values. None can be used as well, to make NULL.FZ__iter__NTz IS NOT NULLz1 = 1z IS NULLz1 = 0z != ?z = ?z	 NOT IN (z IN (r   r)   r*   Z(z IS NOT NULL AND z IS NULL OR )Zhasattrr+   r<   r   Zremover   r/   r.   )	r$   r   r   r;   Z	also_nullr   ZsqlZiZvs	   &&&&     r   _create_filterr>      sM    Iuj!!*UC*@*@e6>MM$I		
6{a--))
6{afQi !'uowd^%+y!E7%f%DAMM!1ut3JC	 &
 	s
ug.se155ug\#a00
r	   c                 s   R V,          p. p. pT;'       g    /  F@  p	VP                  RV	,          4       VP                  RW),          ,           R,           4       KB  	  T;'       g    /  F%  p	VP                  \        WV	,          V4      4       K'  	  T;'       g    /  F'  p	VP                  \        WV	,          VRR7      4       K)  	  V'       d    VRRP                  V4      ,           ,          pV'       dE   TRRP                  V U
u. uF  q^ ,          : R	V
^,          : 2NK  	  up
4      ,          ,          pM	VR
,          p\        W\	        V4      4      # u up
i )zselect * from %sz	%s LIKE ?Z%T)r;   z WHERE r#   z ORDER BY %sr   r9   z ORDER BY slug ASC)r/   r>   r   r8   r   )r   r   ZsearchesZfiltersZexcludesZsortsr   r   Zsql_filtersr$   Zsorts   &&&&&&     r   filtered_queryr?      s%   &EFKR;./cHO+c12   B>%HI R>%%&QUVW  W\\+666$))V[,\V[dQa-IV[,\"]]]%%GE&M22 -]s   
Er   )NN)r   )F)NNNN)r
   Z	threadingZtypingr   ZRLockr   Zobjectr   r   r"   r'   r(   r7   r8   r:   r>   r?   r   r	   r   <module>r@      sX       //
 
 ]
D.b3r	   