mfddlZddlZddlZddlZddlZddlTddlmZddlmZddlmZddlm Z ddlm Z ddlm Z dd lm Z dd lm Z dd lmZdd lmZdd lmZ ddlmZmZmZmZmZmZmZmZmZmZmZdZn #e$rdZYnwxYwejddkre Z!dZ"dZ#eej$dddkrdndZ%ndZ%dZ&Gdde'Z(Gdde(Z)Gdde'Z*Gdde+Z,Gdd eZ-Gd!d"e.Z/Gd#d$e0Z1Gd%d&e2Z3Gd'd(e4Z5Gd)d*e5Z6Gd+d,e6Z7d-Z8e9d.e9e8ze9e8:ze9e;d/fzZ<e9d0e=d1DZ>[8[<ej?d2Z@Gd3d4e6ZA dNd5ZBGd6d7e5ZCd8e _Dd9ZEGd:d;eFZGer@dZHdZMd?ZNd@ZOdAZPdBZQdZRdZWd?ZXd@ZYdAZZdBZ[dCZ\dOdDZ]dPdEZ^GdFdGeGZ_dHZ`dIZadJZbdKZcdLZddMZedS)QN)*) ColumnBase)EnclosedNodeList)Entity) Expression)Insert)Node)NodeList)OP) VirtualField) merge_dict)sqlite3) backupbackup_to_fileBlobConnectionHelperregister_bloomfilterregister_hash_functionsregister_rank_functionssqlite_get_db_statussqlite_get_status TableFunctionZeroBlobTFpcxpcnalx)rr)r rc.eZdZdZdxZxZZfdZxZS) RowIDFieldTrowidc||jkr'tt|d|jdtt|j||g|RdS)Nz must be named "z".) required_name ValueErrortypesuperr!bind)selfmodelnameargs __class__s K/opt/imunify360/venv/lib64/python3.11/site-packages/playhouse/sqlite_ext.pyr(zRowIDField.bind8sm 4% % %"4jjjj$*<*<*<>?? ?$j$$UD84888888) __name__ __module__ __qualname__auto_increment column_namer+r$r( __classcell__r-s@r.r!r!4sLN)00K0$999999999r/r!ceZdZdxZxZZdS) DocIDFielddocidN)r0r1r2r4r+r$r/r.r8r8?s)00K0$r/r8ceZdZfdZxZS)AutoIncrementFieldctt||}t|t dfS)N AUTOINCREMENT)r'r<ddlr SQL)r)ctx node_listr-s r.r?zAutoIncrementField.ddlDs<,d3377<< C$8$89:::r/)r0r1r2r?r5r6s@r.r<r<Cs8;;;;;;;;;r/r<ceZdZdZdZdS) TDecimalFieldTEXTcdSNr:r)s r. get_modifierszTDecimalField.get_modifiersKsr/N)r0r1r2 field_typerIr:r/r.rDrDIsJ!!!!!r/rDceZdZdfd ZedZdZddZddZddZ ddZ dd Z d Z d Z d Zd ZdZdZdZxZS)JSONPathNcvtt|||_|pd|_dSNr:)r'rL__init___field_path)r)fieldpathr-s r.rOzJSONPath.__init__Os5 h&&((( ZR r/cVtdd|jzS)Nz$%s)ValuejoinrQrHs r.rSz JSONPath.pathTs#URWWTZ000111r/ct|ts|dkrd|z}nd|z}t|j|j|fzS)N#z[%s]z.%s) isinstanceintrLrPrQ)r)idxitems r. __getitem__zJSONPath.__getitem__XsK c3   3#::C>>r/c|st|ttfr2t|j|}||j|j|SrG)rZr`rarbrcrPrdrS)r)funcrgrhs r._json_operationzJSONPath._json_operationdsX  ww*6rt{DI>>>*.+77 7r/rG)r0r1r2rOpropertyrSr^rirlrorqrtrxr{r}rrrrr5r6s@r.rLrLNsC      22X2;;;???? 3333 DDDDAAAAEEEEMMM666444<<<4444447777777r/rLcfeZdZdZdZdfd ZdZdZdZee j Z ee j Z ee jZee jZee jZee jZejZdZd Zd Zd Zdd Zdd ZddZddZdZ dZ!dZ"ddZ#dZ$dZ%xZ&S) JSONFieldJSONFNc |p tj|_|p tj|_t t |jdi|dSrN)rcdumpsrdloads _json_loadsr'rrO)r) json_dumps json_loadskwargsr-s r.rOzJSONField.__init__sJ%3%3'i'11&11111r/ch|/ ||S#ttf$r|cYSwxYwdSrG)r TypeErrorr%rws r. python_valuezJSONField.python_valuesR   ''...z*       s //c|Dt|ts-t||}|SdSrG)rZr rbrcrdrws r.db_valuezJSONField.db_valuesF  eT** 9 0 0 7 788L  r/cfd}|S)Nct|ttfrt||jd}t ||S)NF) converterunpack)rZr`rarVrr)r)rhsops r.innerzJSONField._e..innersB#d|,, HC4=GGGdB,, ,r/r:)rrs` r._ez JSONField._es# - - - - - r/c,t||SrG)rL)r)r]s r.r^zJSONField.__getitem__s~~d##r/c>d|D}tj|g|RS)Nc0g|]}t|dS)Fr)rV.0ps r. z%JSONField.extract..s%:::qqE***:::r/)rbrr)pathss r.extractzJSONField.extracts-::E:::t,e,,,,r/cBt|dt|dS)Nz->FrrrVr)rSs r. extract_jsonzJSONField.extract_jsons!$eDE&B&B&BCCCr/cBt|dt|dS)Nz->>Frrrs r. extract_textzJSONField.extract_texts!$uTU'C'C'CDDDr/cHt|||SrG)rLrirfs r.rizJSONField.append~~$$UG444r/cHt|||SrG)rLrorfs r.rozJSONField.insertrr/cHt|||SrG)rLrqrfs r.rqz JSONField.sets~~!!%111r/cHt|||SrG)rLrtrfs r.rtzJSONField.replaces~~%%eW555r/cFt||SrG)rLrx)r)datas r.rxzJSONField.updates~~$$T***r/cl|s!t|Stj|g|RSrG)rLr{rbrzrs r.r{zJSONField.removes: +D>>((** *~d+U++++r/c6t|SrG)rbr}rHs r.r}zJSONField.json_type||D!!!r/c0|r||fn|f}tj|SrG)rbr)r)rSr,s r.rzJSONField.lengths$#0d||$#T**r/c6t|S)a? Schema of `json_each` and `json_tree`: key, value, type TEXT (object, array, string, etc), atom (value for primitive/scalar types, NULL for array and object) id INTEGER (unique identifier for element) parent INTEGER (unique identifier of parent element or NULL) fullkey TEXT (full path describing element) path TEXT (path to the container of the current element) json JSON hidden (1st input parameter to function) root TEXT hidden (2nd input parameter, path at which to start) )rbrrHs r.rzJSONField.childrens||D!!!r/c6t|SrG)rbrrHs r.rzJSONField.treerr/)NNrG)'r0r1r2rJrrOrrrr EQ__eq__NE__ne__GT__gt__GTE__ge__LT__lt__LTE__le__Field__hash__r^rrrrirorqrtrxr{r}rrrr5r6s@r.rrsJ F222222   RYYF RYYF RYYF RZZF RYYF RZZF~H$$$---DDDEEE5555555522226666+++,,, """++++"""""""""""r/rcJeZdZd fd ZdZedZdZd d ZxZ S) SearchFieldFNc |rtdt|ztt|||ddS)Nz8SearchField does not accept these keyword arguments: %s.T) unindexedr4null)r%sortedr'rrO)r)rr4kr-s r.rOzSearchField.__init__sm  ;.06q :;; ; k4  ))I6A * N N N N Nr/c"t||SrG)match)r)terms r.rzSearchField.matchsT4   r/ct|ds:d|jjjD}||j|_|jS)N_fts_column_indexcFg|]}t|t|jSr:)rZrr+)rfs r.rz0SearchField.fts_column_index..s8<<< *1k : :.!sDDDc!ffDDDr/ UNINDEXEDc,g|]}t|Sr:rrs r.rzCVirtualTableSchemaManager._create_virtual_table..-s===c!ff===r/)r* clean_optionsr roptions_create_contextliteralrextension_modulerZr r@prefix_argumentsextendrr!_hiddenrr4rrir arguments_create_table_option_sqlr) r)saferrA ext_modulermetarR field_defs r._create_virtual_tablez/VirtualTableSchemaManager._create_virtual_tables&*** tz'/ 9 9;;""$$ +,,,  * KK( ) ) ) #dj// ')   Z%6 j$ ' ' '77:&& & J  ((--- z   F   DDd.CDDD E E E' 2 2E%*.. %-  1223I 3  [!1!1222   Xi00 1 1 1 1 > ?   ==dn=== > > >  E   T::7CC D D Dww' 22333r/c t|jtr|j|fi|St t |j|fi|SrG) issubclassr* VirtualModelr r'r _create_table)r)rrr-s r.r z'VirtualTableSchemaManager._create_table3sd dj, / / ?-4-d>>g>> >Cu.55C  r/T)r0r1r2r r r5r6s@r.rrsR)4)4)4)4Vr/rc>eZdZGddZedZdS)r c"eZdZdZdZdZdZeZdS)VirtualModel.MetaNF) r0r1r2rrr primary_keyrschema_manager_classr:r/r.Metar<s,  8r/rc|SrGr:)clsrs r.rzVirtualModel.clean_optionsCsr/N)r0r1r2r classmethodrr:r/r.r r ;sW99999999[r/r c$eZdZedZdS) BaseFTSModelcF|d}|d}|d}t|tr |dkrd|d<n.Ys":":":a3q66":":":r/z'%s'z' fts5"%s")getrZ basestringrrr*r table_namer4r`tuplerWstriprlower)rrrrrs r.rzBaseFTSModel.clean_optionsIs&++i((X&&;;z** gz * * =w"}}!%GI    ' ' =!' (;(F(/(;"="=GI   <&4-00 <":":6":":":;; &d);); ;GH   4 288::fDD#)8"3GJ r/N)r0r1r2rrr:r/r.rrHs-[r/rceZdZdZeZGddZedZedZ edZ edZ edd Z edd Z ed ZedZedZedZedZedZe ddZe ddZe ddZe ddZdS)FTSModelz VirtualModel class for creating tables that use either the FTS3 or FTS4 search extensions. Peewee automatically determines which version of the FTS extension is supported and will use FTS4 if possible. ceZdZdezZdS) FTSModel.MetazFTS%sN)r0r1r2 FTS_VERSIONrr:r/r.rr-ms"[0r/rc |jj}|jjd|d|d|d}|S)Nz INSERT INTO (z ) VALUES('z');)rr&database execute_sqlfetchone)rcmdtblress r._fts_cmdzFTSModel._fts_cmdpsOi"i ,,,25##sssCCC @BB||~~r/c,|dSNoptimizer7rs r.r:zFTSModel.optimizew||J'''r/c,|dSNrebuildr;r<s r.r@zFTSModel.rebuild{||I&&&r/c,|dS)Nintegrity-checkr;r<s r.integrity_checkzFTSModel.integrity_checks||-...r/c8|d|d|S)Nzmerge=rr;)rblockssegmentss r.mergezFTSModel.merges!|||VVVXX>???r/Tc:|d|rdpdzS)Nz automerge=%s10r;)rstates r. automergezFTSModel.automerges"||Nem.BsCDDDr/c6t|jj|SzU Generate a `MATCH` expression appropriate for searching this table. rrrrrs r.rzFTSModel.match SY%t,,,r/czt|jjt}tj|g|RSrG)rb matchinforrFTS3_MATCHINFOfts_rank)rweightsrVs r.rankz FTSModel.ranks2LL!1>BB {9/w////r/czt|jjt}tj|g|RSrG)rbrVrrFTS4_MATCHINFOfts_bm25rrY match_infos r.bm25z FTSModel.bm25s2\\#)"2NCC {:00000r/czt|jjt}tj|g|RSrG)rbrVrrr\ fts_bm25fr^s r.bm25fzFTSModel.bm25fs2\\#)"2NCC |J11111r/czt|jjt}tj|g|RSrG)rbrVrrr\ fts_lucener^s r.lucenezFTSModel.lucenes2\\#)"2NCC }Z2'2222r/c|s |}nut|tr[g}|jjD]F} || || jd} || G||}n||}d} |} |r|||f} |r|st|} |j | | | | S)N?r:) rZrarrr$r+rialiasr@selectwhererorder_by) rrrY with_score score_aliasscore_fnexplicit_orderingrZ weight_argsrR field_weight selectionrls r._searchzFTSModel._searchs &8::DD  & & &K0 1 1 '{{5'++ej#2N2NOO ""<00008[)DD8W%D   7djj556I  (/ (;''H$syy''(## %r/NFscorec@||||||j|S'Full-text search using selected `term`.)rtrZrrrYrmrnrps r.searchzFTSModel.search.{{     H   r/c@||||||j|Sz:Full-text search for selected `term` using BM25 algorithm.)rtr`rys r. search_bm25zFTSModel.search_bm25r{r/c@||||||j|Sr})rtrcrys r. search_bm25fzFTSModel.search_bm25fs.{{     I   r/c@||||||j|Sr})rtrfrys r. search_lucenezFTSModel.search_lucenes.{{     J   r/)rErFrNFruF)r0r1r2__doc__r8r9rrr7r:r@rDrJrOrrZr`rcrfrtrzr~rrr:r/r.r+r+dsA JLLE11111111[ (([(''['//[/@@@[@EEE[E--[- 00[011[122[233[3%%[%6FM!&   [ 8=;@   [ 9>rs8KK3q663J3JSVV3J3J3J3JKKr/z(?:[^\s"]|"(?:\\.|[^"])*")+c*eZdZdZeZGddZddddZedZ ed Z e d Z e e d fd Zed ZedZedZe d"dZe d"dZedZedZedZedZedZedZedZedZedZed#dZed$d!ZdS)% FTS5Modelan Requires SQLite >= 3.9.0. Table options: content: table name of external content, or empty string for "contentless" content_rowid: column name of external content primary key prefix: integer(s). Ex: '2' or '2 3 4' tokenize: porter, unicode61, ascii. Ex: 'porter unicode61' The unicode tokenizer supports the following parameters: * remove_diacritics (1 or 0, default is 1) * tokenchars (string of characters, e.g. '-_' * separators (string of characters) Parameters are passed as alternating parameter name and value, so: {'tokenize': "unicode61 remove_diacritics 0 tokenchars '-_'"} Content-less tables: If you don't need the full-text content in it's original form, you can specify a content-less table. Searches and auxiliary functions will work as usual, but the only values returned when SELECT-ing can be rowid. Also content-less tables do not support UPDATE or DELETE. External content tables: You can set up triggers to sync these, e.g. -- Create a table. And an external content fts5 table to index it. CREATE TABLE tbl(a INTEGER PRIMARY KEY, b); CREATE VIRTUAL TABLE ft USING fts5(b, content='tbl', content_rowid='a'); -- Triggers to keep the FTS index up to date. CREATE TRIGGER tbl_ai AFTER INSERT ON tbl BEGIN INSERT INTO ft(rowid, b) VALUES (new.a, new.b); END; CREATE TRIGGER tbl_ad AFTER DELETE ON tbl BEGIN INSERT INTO ft(fts_idx, rowid, b) VALUES('delete', old.a, old.b); END; CREATE TRIGGER tbl_au AFTER UPDATE ON tbl BEGIN INSERT INTO ft(fts_idx, rowid, b) VALUES('delete', old.a, old.b); INSERT INTO ft(rowid, b) VALUES (new.a, new.b); END; Built-in auxiliary functions: * bm25(tbl[, weight_0, ... weight_n]) * highlight(tbl, col_idx, prefix, suffix) * snippet(tbl, col_idx, prefix, suffix, ?, max_tokens) ceZdZdZdS)FTS5Model.Metar"Nr0r1r2rr:r/r.rr8s!r/rzQBesides the implicit `rowid` column, all columns must be instances of SearchFieldz3Secondary indexes are not supported for FTS5 modelsz4FTS5 models must use the default `rowid` primary key)rJrpkc^|jjjdkrt|jd|jjD]8}t|ttfst|jd9|jj rt|jddS)Nr"rrJr) rrr+ImproperlyConfigured_error_messagesfieldsvaluesrZrr!indexes)rrRs r.validate_modelzFTS5Model.validate_modelBs 9 % 0 0&s':4'@AA AY%,,.. N NEek:%>?? N*3+>|+LMMM N 9  E&s':7'CDD D E Er/ctjddtkrdStjd} |dno# |d|d|jjdn#YY| dSxYwYnxYw| n#| wxYwdS)NrFz:memory:z0CREATE VIRTUAL TABLE fts5test USING fts5 (data);Tr") rsqlite_version_infoFTS5_MIN_SQLITE_VERSIONconnectexecuteenable_load_extensionload_extensionrr1close)rtmp_dbs r.fts5_installedzFTS5Model.fts5_installedMs  &rr *-D D D5,,  NNM N N N N : :,,T222%%f--- "11&9999 u LLNNNNN:9 LLNNNNFLLNNNNtsAA C B7*B8 B7B2B7C2B75CC%ct|}|D]G}|dr|dr-t |t zrdSHdS)z Simple helper function to indicate whether a search query is a valid FTS5 query. Note: this simply looks at the characters being used, and is not guaranteed to catch all problematic queries. "FT) _quote_refindall startswithendswithrq_invalid_ascii)querytokenstokens r.validate_queryzFTS5Model.validate_querycsv""5))  E$$ )<)< 5zzN* uu tr/rcg}d}t|}|D]}|dr+|dr||Bt |}|t z}|rd}|D]}|||}|||rd|S|S)z2 Clean a query of invalid tokens. FrTr) rrrrrirqrrtrW) rrtaccum any_invalidrr token_setinvalid_for_tokencs r. clean_queryzFTS5Model.clean_queryrs  ""5)) E$$ )<)<  U###E I )N :   6" *66A!MM!W55EE LL      #88E?? " r/c6t|jj|SrQrRrSs r.rzFTS5Model.matchrTr/c8|r |j|ntdS)NrZ)r`r@)rr,s r.rZzFTS5Model.ranks"&7xsxCKK7r/c:tj|jjg|RSrG)rbr`rr)rrYs r.r`zFTS5Model.bm25swsy'2'2222r/NFrucd|t|||||Srw)r~rrrys r.rzzFTS5Model.searchs7  ! !$ ' '      r/c |std}nt|trg}|jjD]`}t|t rI|jsB|||||j datj |jj g|R}ntj |jj g|R}d} |} |r|| |f} |r|st|} |j| |t"|| S)rxrZrhr:)r@rZrarrrrrir$r+rbr`rrirjrkrrrrl) rrrYrmrnrprZrqrRrsrls r.r~zFTS5Model.search_bm25si 7v;;DD  & & 7K0 J Je[11J%/J&& E7;;uz3+G+GHHJJJ739+:k:::DD739+6g666D   7djj556I  (/ (;''H$syy!6!6t!>(## %r/c l|jj}|g}|g}|D]<\}}|t |||=t t d|jjt|t dt|fS)Nz INSERT INTOVALUES)rritemsrirr r@r)rr4 extra_paramsr5columnsrkeyrgs r. _fts_cmd_sqlzFTS5Model._fts_cmd_sqlsi%&,,.. ! !JC NN6#;; ' ' ' MM%     I  W % % MM V $ $ &'' 'r/c \|j|fi|}|jj|SrG)rrr1r)rr4rrs r.r7zFTS5Model._fts_cmds5  55 55y!))%000r/cld|cxkrdksntd|d|S)Nrrzlevel must be between 0 and 16rOrZ)r%r7)rlevels r.rOzFTS5Model.automergesFU    b    =>> >||Ke|444r/c0|d|S)NrJrr;)rnpagess r.rJzFTS5Model.merges||G&|111r/c,|dSr9r;r<s r.r:zFTS5Model.optimizer=r/c,|dSr?r;r<s r.r@zFTS5Model.rebuildrAr/c0|d|S)Npgszrr;)rrs r.set_pgszzFTS5Model.set_pgszs||F|...r/c0|d|S)NrZrr;)rrank_expressions r.set_rankzFTS5Model.set_ranks||F|999r/c,|dS)Nz delete-allr;r<s r. delete_allzFTS5Model.delete_alls||L)))r/rc0|d|S)NrCrr;)rrZs r.rDzFTS5Model.integrity_checks||-D|999r/rowc dvrtddz}t|sGfdd}ttt t t |d}dkrtt|d<ndkrtt|d <d jz}t|t|tf|t|S) N)rcolinstancez5table_type must be either "row", "col" or "instance".z_vocab_model_%sceZdZjjZpjjdzZejje Z dS)"FTS5Model.VocabModel..Meta_vN) r0r1r2rr1r&rb fts5vocabrr@r)rtable table_typesr.rrsV9-"Aci&:T&A #%<<I$C OO$%$%   r/r)rdoccntr"rrroffsetz%sVocab) r%rr TextField IntegerFieldr!r0setattrr&r getattr)rrrattrrattrs class_names``` r. VocabModelzFTS5Model.VocabModels, 7 7 7+,, ,!:-sD!! I % % % % % % % % % % % %%Y//#~~#~~# EU""+I66e z))".|"<"<h"S\1J CtJGG H H HsD!!!r/r)r)rN)r0r1r2rr!r"rrrrr staticmethodrrrrrZr`rzr~rr7rOrJr:r@rrrrDrr:r/r.rrs44n JLLE""""""""5FD OEE[E[*  \ #&3r77\.--[- 88[833[3FM!&[8=;@%%%[%6 ' '[ '11[155[5 22[2(([(''['//[/::[:**[*:::[:"""["""r/rc+jjD]}|jur|ntdjjGfddt }Gfdd}djz}t||fd|iS)z3Model factory for the transitive closure extension.Nz,Unable to find self-referential foreign key.ceZdZeeZeeZeeZeeZ eeZ eeZ GddZ e dfd Ze dfd Ze d fd ZdS) &ClosureTable..BaseClosureTableceZdZdZdS)+ClosureTable..BaseClosureTable.Metatransitive_closureNrr:r/r.rr3s3   r/rNFc~|jd||jk|j|k}|||j|k}n |s||jdk}|SNdepthonr)rjrrirWidrkrootobjectsrnoder include_noder model_class source_keys r. descendantsz2ClosureTable..BaseClosureTable.descendants6s f[#)//'*B*BCCd3J#&$8d::eCH,--gii    CI$677! 3 CIM22Lr/c~|jd||jk|j|k}|r||j|k}n |s||jdk}|Sr)rjrrirWrrkrrrs r. ancestorsz0ClosureTable..BaseClosureTable.ancestorsCs f[#)//'*B*BCCd3J#($:d<<eCFdN++gii   3 CI$677! 3 CIM22Lr/c urK|jj}|k}n ||jk|j|k|jdkz} |z }|s| |k}|S)Nr) __data__r$r+rjrkrWrrrr) rrrfk_valuersiblings foreign_keyrreferencing_classreferencing_keyrs r.rz/ClosureTable..BaseClosureTable.siblingsPs K//=,,[-=>>#**,,22;(3JKK.#VO44!T#;#(+BTDD"UCFdNsyA~#FGG % &((% h 677!'))   8 J$$677Lr/NFF)r0r1r2r rrrridcolumn parentcolumnr tablenamerrrrr)rrrrrsr.BaseClosureTabler+s3 \** \, ' '< **#|I.. |L)) L++  4 4 4 4 4 4 4 4                                r/r c`eZdZjjZjjjjdZdZdS)ClosureTable..Meta)r rr FN) r0r1r2rr1r&r4rr)rrrsr.rr hsB$*3*0;'3'355 r/rz %sClosure)rrefs rel_modelr%rr r0r&) rrrr field_objr rr+rs ```` @r. ClosureTablers$ '$*/ M MI"k11' 2KLL L".J$;;;;;;;;;;;<;;;z - -D ')FD> : ::r/ceZdZGddZedZed dZedZedZ edZ ed Z ed Z d S) LSMTableceZdZdZdZdS) LSMTable.Metalsm1N)r0r1r2rfilenamer:r/r.rrus!r/rc|jj}|stdt|dkr|ddkrd|z}|jjstd|jj}t |t rtdt |tttfstdd |_ t |trd }nt |trd }nd }|d|j z|g|j_ t|jj dkr|jj d |j_n d|j_|S)NzILSM1 extension requires that you specify a filename for the LSM database.rrr#z-LSM1 models must specify a primary-key field.z8LSM1 models must explicitly declare a primary key field.z9LSM1 key must be a TextField, BlobField, or IntegerField.TUINTBLOBrEr)rrr%lenrrZ AutoFieldr BlobFieldrrr+rr _value_field)rrrr data_types r.rzLSMTable.clean_optionsysl9% ->?? ?8}}!!hqkS&8&8!H,y$ NLMM Mi# c9 % % +*++ +# 9lCDD .-.. . c< ( ( II Y ' ' III&.0A9%M " sy& ' '1 , ,%(Y%FF # # t"U  # t $ $ "DD s # # ">D&)SY "# D!!#####r/c|||jj|\}}|SrG)r-deleterrr)rrrr1s r. delete_by_idzLSMTable.delete_by_idsB55 JJLL I ! y}}r/N)r!) r0r1r2rrrrrr'r-r2r7r:r:r/r.rrts!![!F000[0##\# 4 4\ 4  [  $ $[ $[r/rMATCHc0tj||duSrG)rerz)regexrgs r._sqlite_regexpr?s 9UE " "$ ..r/c6eZdZ dfd ZfdZdZxZS)SqliteExtDatabaseNTFctt|j|g|Ri| d|_|rtst dto|du} |r~| rt |nl|td|td|td|td|r | stdt||r|tdd |r | std t||r|td | |_dS) NzRSqliteExtDatabase initialized with C extensions, but shared library was not found!Fr]rXrbrez0C extension required to register hash functions.regexprz(C extension required to use bloomfilter. json_contains)r'rArO _row_factoryCYTHON_SQLITE_EXTENSIONSrrregister_functionr`rZr%rr?r_json_contains _c_extensions) r)r1 c_extensionsrank_functionshash_functionsregexp_function bloomfilterrDr,rprefer_cr-s r.rOzSqliteExtDatabase.__init__s 0&&/J4JJJ6JJJ   5 8 5&(455 5,KU1J  ; ;'----&&tZ888&&tZ888&&t[999&&t\:::  * / "./// #D ) ) )  @  " ">8Q ? ? ?  ' M !KLLL  & & &  D  " ">? C C C%r/ctt|||jr|j|_dSdSrG)r'rA_add_conn_hooksrE row_factoryr)connr-s r.rQz!SqliteExtDatabase._add_conn_hookssH &&66t<<<   1#0D    1 1r/c||_dSrG)rEr)rbs r.rRzSqliteExtDatabase.row_factory sr/)NTFFFF)r0r1r2rOrQrRr5r6s@r.rArAsoCG7<27!&!&!&!&!&!&F11111 r/rArrrrFr c0fd}t|S)zt Expose a sqlite3_status() call for a particular flag as a property of the Database object. c:t}r|dn|Sr/)r)r)resultflagreturn_highwaters r.getterz__status__..getter+s#&t,,F 0<6!99f .getter6sV{'*+LMMM)$+*:DAAF !ay 0<6!99f BBBBB C Cr/cp||_|s|j||SrG)rk is_closedrjrsrVs r. on_commitzCSqliteExtDatabase.on_commit`8 "D >>## 6!11"555Ir/cp||_|s|j||SrG)rlr|rjrtrVs r. on_rollbackzCSqliteExtDatabase.on_rollbackfs8"$D >>## 8!33B777Ir/cp||_|s|j||SrG)rmr|rjrurVs r. on_updatezCSqliteExtDatabase.on_updatelr~r/c4|jSrG)rjchangesrHs r.rzCSqliteExtDatabase.changesrs$,,.. .r/c4|jSrG)rjlast_insert_rowidrHs r.rz$CSqliteExtDatabase.last_insert_rowidus$6688 8r/c4|jSrG)rj autocommitrHs r.rzCSqliteExtDatabase.autocommitys$//11 1r/Ncrt|||||SN)pagesr+progress)r connection)r) destinationrr+rs r.rzCSqliteExtDatabase.backup}s>$//++[-C-C-E-E %D8EEE Er/cNt|||||Sr)rr)r)rrr+rs r.rz!CSqliteExtDatabase.backup_to_files2!$//"3"3XU'+h@@@ @r/c(t|||||SrG)r)r)rcolumnr" read_onlys r. blob_openzCSqliteExtDatabase.blob_openseVUI>> >r/TrNNN):r0r1r2rOrprvrQr}rrrrrrrrrraSQLITE_STATUS_MEMORY_USED memory_usedSQLITE_STATUS_MALLOC_SIZE malloc_sizeSQLITE_STATUS_MALLOC_COUNT malloc_countSQLITE_STATUS_PAGECACHE_USEDpagecache_used SQLITE_STATUS_PAGECACHE_OVERFLOWpagecache_overflowSQLITE_STATUS_PAGECACHE_SIZEpagecache_sizeSQLITE_STATUS_SCRATCH_USED scratch_usedSQLITE_STATUS_SCRATCH_OVERFLOWscratch_overflowSQLITE_STATUS_SCRATCH_SIZE scratch_sizerfSQLITE_DBSTATUS_LOOKASIDE_USEDlookaside_usedSQLITE_DBSTATUS_LOOKASIDE_HIT lookaside_hit#SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZElookaside_miss#SQLITE_DBSTATUS_LOOKASIDE_MISS_FULLlookaside_miss_fullSQLITE_DBSTATUS_CACHE_USED cache_usedSQLITE_DBSTATUS_SCHEMA_USED schema_usedSQLITE_DBSTATUS_STMT_USEDstatement_usedSQLITE_DBSTATUS_CACHE_HIT cache_hitSQLITE_DBSTATUS_CACHE_MISS cache_missSQLITE_DBSTATUS_CACHE_WRITE cache_writer5r6s@r.rhrh?s F F F F F  > > > > > > @ @ @ @ @ C C C C C             / / /  9 9  9  2 2  2 E E E E=A$( @ @ @ @  ? ? ? ?!j!:;;  j!:DAA !z"<== #$@AA'Z(HII#$@$GG!z"<== %:&DEE!z"tLL %&?MM L!:E4HH !\"tLL r/rhc8t|tj|SrG)rr r;)lhsrs r.rrs c28S ) ))r/c\t}fdtd|dDS)Nc \g|](}tjd||dzd)S)z@Irr)structr)rr!bufs r.rz%_parse_match_info..s6 M M M1FM$AacE + +A . M M Mr/rr)rrange)rbufsizes` r._parse_match_infors4#hhG M M M Ma!8L8L M M MMr/cV|sdg|zSdg|z}t|D] \}}|||< |S)Nrr) enumerate)ncol raw_weightsrYr!weights r. get_weightsrsL  sTz#*";//  IAvGAJJ Nr/cJt|}d}|dd\}}t||}t|D]c}d||zdzz}t|D]F} || } | s || dzz} || } || dz} | dkr|| t| | z zz }Gd| S)Nrrrr)rrrfloat)raw_match_inforr_rurrrY phrase_numphrase_info_idxcol_numrcol_idxrow_hits all_rows_hitss r.rZrZs#>22J E bqb>DAq![))GAhhDD zA~12Qxx D DGW%F %15G "'*H&w{3M!||5??]#BCC D 6Mr/ct|}d}d}d}td\}}}} ||} ||} ||} | | z} | | z}t| |}t| D]}t| D]}||}|dkr|d||| zzzz}t||}t||dz}t j| |z dz|dzz }|dkrd }t|| |z}t|| |zpd }||z }||d zz}d |z ||zz}|||zz}|||z z}|||zz }׌| S) z Usage: # Format string *must* be pcnalx # Second parameter to bm25 specifies the index of the column, on # the table being queries. bm25(matchinfo(document_tbl, 'pcnalx'), 1) AS rank g333333?g?rrrrrg?gư>rh)rrrrmathlog)rr,r_KBruP_OC_ON_OA_O term_count col_count total_docsL_OX_OrYr!jrxterm_frequencydocs_with_termidf doc_length avg_lengthrationumb_partdenompc_scores r.r`r`s#>22J A A EqCc3CJ3ICJ /C /C:)T**G :  ))y!! ) )AQZF{{qAI -./A":a=11N":a!e#455N(.036#c)+,,Cczzz#'233Jz#'2339rJ+E AG,C1WE *F"a&j1EcEk*H h' (EE3 )6 6Mr/cg} |tj|tj|fn#YdSxYw|rB|\}}t |t rnt |t r0|D],}||vrdS|||||f-nt |t r |D] }||vrdS n||vrdSnt |t rt |t rdSt |t rU tt|D]%}|||||f&n #t$rYdSwxYw||vrdSn||krdS|BdSr)) rircrpoprZrar`rr IndexError)src_jsonobj_jsonstackobjsrcrr]r!s r.rHrH,s E dj**DJx,@,@ABBBBuu 99;;S c4  #t$$ 77C#~~$uuLL#c(CH!566667C&& %%D3$uu'%Cu T " " #t$$ uC&& !"3s88__77 c!fc!f%566667!!!! 55!Cu CZZ55 6 4s;AA'AE** E87E8rr)FF)frcrr=rsyspeeweerrrrrr r r r r rplayhouse._sqlite_extrrrrrrrrrrrrF ImportError version_infor r%rWr\rr.rrr!r8r< DecimalFieldrDrLrrrr SchemaManagerrModelr rr+ _alphabetrqupperrrrrcompilerrrrr;r?SqliteDatabaserArrrrrrSQLITE_STATUS_PARSER_STACKrrrrrrrrrrrrrSQLITE_DBSTATUS_DEFERRED_FKSrarfrhrrrrZr`rHr:r/r.rs ######%                           $%%%$%A!J 22A26)CC!!KKK#9999999911111111;;;;;;;; """""L""" 8787878787z878787v\"\"\"\"\" \"\"\"~33333%333>11111 111h     5   <8LLLLL|LLL^ ) S* + + S^^ S"" # #$S##b''__ KKUU3ZZKKKKK  BJ5 6 6 X"X"X"X"X" X"X"X"vCG!%X;X;X;X;vddddd|dddN ///********ZTM !#$ '($!"%&" !!"#$ !"!"%&"!""# !$%!*+'*+' !!""##%          cMcMcMcMcM.cMcMcML***NNN !!!HNNNb#####sA99BB