Package: py-linq-sql
Py-Linq-SQLA Python module used for interacting with sql database usingLINQsyntax. The project is underEUPL License v1.2.Py-linq-sql allows you to go from (SQLAlchemy using direct text query):conn.execute(text("""SELECT "data"->'obj'->'name' as name """"""FROM "objects" """"""WHERE "data"->'obj'->>'name' == "earth" """"""AND CAST("data"->'obj'->'mass' > 0.5 AS Decimal) """"""LIMIT 1 OFFSET 2"""))to the safer and easier to read:sqle=(SQLEnumerable(conn,"objects")# objects is the name of the table.select(lambdax:{"name":x.data.obj.name})# data is a JSONB column.where(lambdax:x.data.obj.mass>0.5)# data is a JSONB column.skip(2).take(1)# this is the last part of the query, till there nothing is executed.execute()# now we ask for the whole query to be executed on the DB server)Pro :all the query expression are expressed in pure python expressioneasy support of JSON database using a simple object notationvery difficult to have an SQL injection (only the names of the tables are strings)standardized syntax/API of LINQ (used in java, C# and many .net languages)very fast: even very long and complex queries are executed in one single query on the
serverno need to define a class for every table in the DB as you would do in an ORM here you
write query assuming the tables, columns and fields exist, if not then you get a clear
error about itresults are pylinq Enumerable that are themselves queryable in same way but locallyall kinds of join (inner, outer and full, with or without intersections) are easy to
use and combine with any kind of queryCons :currently only support PostgresQLAny feedback is welcome seeContributing.ContactsAuthor: Ulysse CHOSSON (LESIA)Maintainer: Ulysse CHOSSON (LESIA)Email:ulysse.chosson@obspm.frContributors:Pierre-Yves MARTIN (LESIA)Table of ContentPy-Linq-SQLContactsTable of ContentInstallImplemented functionsLINQ functionsCustom functionsNot implemented functionsLINQ functionsPy-Linq functionsContributing and info for developersFull documentationInstallFor all specific commands to this project, we usejust.You need to install it.After you can install the dependencies:$justinstallpwd/home/uchosson/Documents/py-linq-sql
poetryinstall--no-dev--remove-untracked
Installingdependenciesfromlockfile
Warning:Thelockfileisnotuptodatewiththelatestchangesinpyproject.toml.
Youmaybegettingoutdateddependencies.Runupdatetoupdatethem.

Nodependenciestoinstallorupdate

Installingthecurrentproject:py-linq-sql(0.109.0)And if you need to develop the project, install development dependencies:$justinstall-allpwd/home/uchosson/Documents/py-linq-sql
poetryinstall--remove-untracked
Installingdependenciesfromlockfile
Warning:Thelockfileisnotuptodatewiththelatestchangesinpyproject.toml.
Youmaybegettingoutdateddependencies.Runupdatetoupdatethem.

Nodependenciestoinstallorupdate

Installingthecurrentproject:py-linq-sql(0.109.0)npminstall

uptodate,audited8packagesin793ms1packageislookingforfundingrun`npmfund`fordetails

found0vulnerabilities
sudonpminstallmarkdownlint-cli2--global

changed36packages,andaudited37packagesin2s8packagesarelookingforfundingrun`npmfund`fordetails

found0vulnerabilitiesand the pre-commit dependencies:$justpreinstallpwd/home/uchosson/Documents/py-linq-sql
pre-commitclean
Cleaned/home/uchosson/.cache/pre-commit.
pre-commitautoupdate
Updatinghttps://github.com/pre-commit/pre-commit-hooks...[INFO]Initializingenvironmentforhttps://github.com/pre-commit/pre-commit-hooks.
alreadyuptodate.
Updatinghttps://github.com/pre-commit/pre-commit-hooks...alreadyuptodate.
Updatinghttps://github.com/pycqa/isort...[INFO]Initializingenvironmentforhttps://github.com/pycqa/isort.
alreadyuptodate.
Updatinghttps://github.com/ambv/black...[INFO]Initializingenvironmentforhttps://github.com/ambv/black.
alreadyuptodate.
Updatinghttps://github.com/codespell-project/codespell...[INFO]Initializingenvironmentforhttps://github.com/codespell-project/codespell.
alreadyuptodate.
Updatinghttps://github.com/sqlfluff/sqlfluff...[INFO]Initializingenvironmentforhttps://github.com/sqlfluff/sqlfluff.
updating1.1.0->1.2.1.
Updatinghttps://github.com/pycqa/flake8...[INFO]Initializingenvironmentforhttps://github.com/pycqa/flake8.
alreadyuptodate.
Updatinghttps://github.com/DavidAnson/markdownlint-cli2...[INFO]Initializingenvironmentforhttps://github.com/DavidAnson/markdownlint-cli2.
alreadyuptodate.
pre-commitinstall--hook-typepre-merge-commit
pre-commitinstalledat.git/hooks/pre-merge-commit
pre-commitinstall--hook-typepre-push
pre-commitinstalledat.git/hooks/pre-push
pre-commitinstall--hook-typepost-rewrite
pre-commitinstalledat.git/hooks/post-rewrite
pre-commitinstall-hooks[INFO]Installingenvironmentforhttps://github.com/pre-commit/pre-commit-hooks.[INFO]Onceinstalledthisenvironmentwillbereused.[INFO]Thismaytakeafewminutes...[INFO]Installingenvironmentforhttps://github.com/pycqa/isort.[INFO]Onceinstalledthisenvironmentwillbereused.[INFO]Thismaytakeafewminutes...[INFO]Installingenvironmentforhttps://github.com/ambv/black.[INFO]Onceinstalledthisenvironmentwillbereused.[INFO]Thismaytakeafewminutes...[INFO]Installingenvironmentforhttps://github.com/codespell-project/codespell.[INFO]Onceinstalledthisenvironmentwillbereused.[INFO]Thismaytakeafewminutes...[INFO]Installingenvironmentforhttps://github.com/sqlfluff/sqlfluff.[INFO]Onceinstalledthisenvironmentwillbereused.[INFO]Thismaytakeafewminutes...[INFO]Installingenvironmentforhttps://github.com/pycqa/flake8.[INFO]Onceinstalledthisenvironmentwillbereused.[INFO]Thismaytakeafewminutes...[INFO]Installingenvironmentforhttps://github.com/DavidAnson/markdownlint-cli2.[INFO]Onceinstalledthisenvironmentwillbereused.[INFO]Thismaytakeafewminutes...
pre-commitinstall
pre-commitinstalledat.git/hooks/pre-commitImplemented functionsLINQ functionsLINQ documentationAll function make before an.execute()are executed by the database server.MDPA = MagicDotPathAggregateMethod NameDescriptionOutputallReturn True if all elements match the predicate.SQLEnumerableanyReturn True if any elements match the predicate.SQLEnumerableavgAggregation function to get the average of the predicate.MDPAcontainsReturn True if at least one element match the predicate.SQLEnumerableconcatAggregation function to concat a predicate.MDPAcountReturn the number of line in a table.SQLEnumerablecountAggregation function to count a predicate.MDPAdistinctReturn all elements that are not duplicate.SQLEnumerableelement_atReturn the element at the specific index.SQLEnumerableelement_at_or_defaultReturn the element at the specific index or None if index > len.SQLEnumerableexceptReturns all elements except elements from another SQLEnumerable.SQLEnumerablefirstReturn the first element match the predicate.SQLEnumerablefirst_or_defaultReturn the first element match the predicate or None if none match.SQLEnumerablegroup_byReturn the selection group by a predicate.SQLEnumerablegroup_joinReturn the join between 2 selections group by a predicate.SQLEnumerableintersectReturn the intersection between 2 selections.SQLEnumerablejoinReturn the join between 2 selections.SQLEnumerablelastReturn the last element match the predicate.SQLEnumerablelast_or_defaultReturn the last element match the predicate or None if none match.SQLEnumerablemaxReturn the max element.SQLEnumerablemaxAggregate function to get the max of predicate.MDPAminReturn the min element.SQLEnumerableminAggregate function to get the min of predicate.MDPAorder_byReturn the selection order by key(s).SQLEnumerableorder_by_descendingReturn the selection order by descending by key(s).SQLEnumerableselectReturn a selection of elements.SQLEnumerablesingleReturn the only element match the predicate.SQLEnumerablesingle_or_defaultReturn the only element match the predicate or None if many matches.SQLEnumerableskipReturn the selection minusXfirst elements.SQLEnumerableskip_lastReturn the selection minusXlast elements.SQLEnumerablesumAggregation function to get the sum of a predicate.MDPAtakeReturnXfirst element of the selection.SQLEnumerabletake_lastReturnXlast element of the selection.SQLEnumerableunionReturn the union between 2 selections.SQLEnumerablewhereReturn the selection with all elements match the predicate.SQLEnumerableFor more information see thedetailed documentation.Custom functionsMethod NameDescriptionOutputdeleteDelete data in a SQL table.SQLEnumerableexecuteExecute a request from an SQLEnumerable.Enumerable or int or bool or dictinsertInsert data in a SQL table.SQLEnumerablesimple_insertInsert data in a relationnal SQL table with kwargs.SQLEnumerableupdateUpdate data in a table.SQLEnumerableNot implemented functionsLINQ functionsMethod NameDescriptionappendNot implementeddefault_if_emptyNot implementedemptyNot implementedprependNot implementedrangeNot implementedrepeatNot implementedreverseNot implementedselect_manyNot implementedskip_whileNot implementedtake_whileNot implementedto_dictionaryNot implementedto_listNot implementedzipNot implementedPy-Linq functionsMethod NameDescriptionaddNot implementedmedianNot implementedPy-Linq linkContributing and info for developersChangelogContributingOur git workflowFull documentationPy-LINQ-SQL Documentation