1"use strict";(self.webpackChunkmistql_docs=self.webpackChunkmistql_docs||[]).push([[5249],{5229:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>c,default:()=>a,frontMatter:()=>d,metadata:()=>s,toc:()=>o});const s=JSON.parse('{"id":"reference/implementations/py","title":"Python Implementation","description":"The Python implementation of MistQL can be installed via pip install mistql. Python 3.8+ is supported.","source":"@site/docs/reference/implementations/py.md","sourceDirName":"reference/implementations","slug":"/reference/implementations/py","permalink":"/docs/next/reference/implementations/py","draft":false,"unlisted":false,"editUrl":"https://github.com/evinism/mistql/edit/docs/docs/reference/implementations/py.md","tags":[],"version":"current","sidebarPosition":2,"frontMatter":{"sidebar_position":2},"sidebar":"tutorialSidebar","previous":{"title":"JS Implementation","permalink":"/docs/next/reference/implementations/js"}}');var i=n(4848),r=n(8453);const d={sidebar_position:2},c="Python Implementation",l={},o=[{value:"Example Usage:",id:"example-usage",level:3},{value:"<code>mistql</code> package exports",id:"mistql-package-exports",level:3},{value:"Type correspondence between Python and MistQL",id:"type-correspondence-between-python-and-mistql",level:3}];function h(e){const t={code:"code",h1:"h1",h3:"h3",header:"header",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t.header,{children:(0,i.jsx)(t.h1,{id:"python-implementation",children:"Python Implementation"})}),"\n",(0,i.jsxs)(t.p,{children:["The Python implementation of MistQL can be installed via ",(0,i.jsx)(t.code,{children:"pip install mistql"}),". Python 3.8+ is supported."]}),"\n",(0,i.jsx)(t.h3,{id:"example-usage",children:"Example Usage:"}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-py",children:"import mistql\n\nlength = mistql.query('count @', [1, 2, 3])\nprint(length)\n"})}),"\n",(0,i.jsxs)(t.h3,{id:"mistql-package-exports",children:[(0,i.jsx)(t.code,{children:"mistql"})," package exports"]}),"\n",(0,i.jsxs)(t.table,{children:[(0,i.jsx)(t.thead,{children:(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.th,{children:"Export"}),(0,i.jsx)(t.th,{children:"type"}),(0,i.jsx)(t.th,{children:"Description"})]})}),(0,i.jsxs)(t.tbody,{children:[(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"query"})}),(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"(query: string, data: any) => any"})}),(0,i.jsx)(t.td,{children:"The query interface for MistQL"})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"__version__"})}),(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"str"})}),(0,i.jsx)(t.td,{children:"The current version of MistQL installed"})]})]})]}),"\n",(0,i.jsx)(t.h3,{id:"type-correspondence-between-python-and-mistql",children:"Type correspondence between Python and MistQL"}),"\n",(0,i.jsxs)(t.p,{children:["Separate from the specification of the language, the python implementation maps from\nPython types to MistQL types in a specific manner, as documented by the table below. As\nthe following is NOT part of the language, rather the library, the correspondence\nmay change with further releases of the ",(0,i.jsx)(t.code,{children:"mistql"})," package, following semver."]}),"\n",(0,i.jsx)(t.p,{children:"Note that this is generally very restrictive in what it allows, but\ncan be easily expanded as necessary. For examples, iterables as a whole may, outside of\nspecific cases, be casted directly to MistQL array types."}),"\n",(0,i.jsx)(t.p,{children:"If this correspondence doesn't work for you for some reason, please open an issue and\ndescribe the situation carefully. This correspondence is easier to change than the language\nitself."}),"\n",(0,i.jsxs)(t.table,{children:[(0,i.jsx)(t.thead,{children:(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.th,{children:"Value"}),(0,i.jsx)(t.th,{children:"MistQL Value"}),(0,i.jsx)(t.th,{children:"Notes"})]})}),(0,i.jsxs)(t.tbody,{children:[(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"int"})}),(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"number"})}),(0,i.jsxs)(t.td,{children:["Infinity and NaN casted to ",(0,i.jsx)(t.code,{children:"null"})]})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"float"})}),(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"number"})}),(0,i.jsx)(t.td,{})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"boolean"})}),(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"boolean"})}),(0,i.jsx)(t.td,{})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"string"})}),(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"string"})}),(0,i.jsx)(t.td,{})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"dict"})}),(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"object"})}),(0,i.jsx)(t.td,{})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"None"})}),(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"null"})}),(0,i.jsx)(t.td,{})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"list"})}),(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"array"})}),(0,i.jsx)(t.td,{})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"tuple"})}),(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"array"})}),(0,i.jsx)(t.td,{})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"datetime.date"})}),(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"date.isoformat()"})}),(0,i.jsx)(t.td,{})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"datetime.time"})}),(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"time.isoformat()"})}),(0,i.jsx)(t.td,{})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"datetime.datetime"})}),(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"datetime.isoformat()"})}),(0,i.jsx)(t.td,{})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:"Anything else"}),(0,i.jsx)(t.td,{children:"Error"}),(0,i.jsx)(t.td,{})]})]})]})]})}function a(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,i.jsx)(t,{...e,children:(0,i.jsx)(h,{...e})}):h(e)}},8453:(e,t,n)=>{n.d(t,{R:()=>d,x:()=>c});var s=n(6540);const i={},r=s.createContext(i);function d(e){const t=s.useContext(r);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:d(e.components),s.createElement(r.Provider,{value:t},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.