{"id":20326053,"url":"https://github.com/matteoguadrini/nosqlapi","last_synced_at":"2026-03-07T21:30:58.217Z","repository":{"id":57446787,"uuid":"374722446","full_name":"MatteoGuadrini/nosqlapi","owner":"MatteoGuadrini","description":"nosqlapi is a library for building standard NOSQL python libraries.","archived":false,"fork":false,"pushed_at":"2022-04-05T07:53:38.000Z","size":1598,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T20:06:17.666Z","etag":null,"topics":["column-database","column-db","column-store","database","document-database","document-db","graph-database","graph-db","key-value-database","keyvalue-db","nosql","nosql-database","nosql-databases","orm","orm-framework","python","python3","selector-engine"],"latest_commit_sha":null,"homepage":"https://nosqlapi.rtfd.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MatteoGuadrini.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-07T15:54:20.000Z","updated_at":"2023-08-28T07:14:48.000Z","dependencies_parsed_at":"2022-09-05T09:40:53.933Z","dependency_job_id":null,"html_url":"https://github.com/MatteoGuadrini/nosqlapi","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatteoGuadrini%2Fnosqlapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatteoGuadrini%2Fnosqlapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatteoGuadrini%2Fnosqlapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatteoGuadrini%2Fnosqlapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MatteoGuadrini","download_url":"https://codeload.github.com/MatteoGuadrini/nosqlapi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248473127,"owners_count":21109628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["column-database","column-db","column-store","database","document-database","document-db","graph-database","graph-db","key-value-database","keyvalue-db","nosql","nosql-database","nosql-databases","orm","orm-framework","python","python3","selector-engine"],"created_at":"2024-11-14T19:42:45.880Z","updated_at":"2026-03-07T21:30:58.097Z","avatar_url":"https://github.com/MatteoGuadrini.png","language":"Python","readme":"# nosqlapi\n\n_nosqlapi_ is a library for building standard NOSQL python libraries.\n\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/69fa15d33f9c4f26b14ffe8403327140)](https://www.codacy.com/gh/MatteoGuadrini/nosqlapi/dashboard?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=MatteoGuadrini/nosqlapi\u0026amp;utm_campaign=Badge_Grade)\n[![CircleCI](https://circleci.com/gh/MatteoGuadrini/nosqlapi.svg?style=svg)](https://circleci.com/gh/MatteoGuadrini/nosqlapi)\n\nFull documentation: [Read the docs](https://nosqlapi.rtfd.io/)\n\n## Introduction\n\nThis library is defined to encourage similarity between Python modules used to access NOSQL databases. \nIn this way, I hope for consistency that leads to more easily understood modules, code that generally gets more \nportability across databases and a broader scope of database connectivity from Python.\n\nThis document describes the Python NOSQL database API specification.\n\n## Module Interface\n\n### Constructors\n\nAccess to the database is made available through _connection_ objects. The module must provide the following constructor for these:\n\n`Connection(parameters...)`\n\nConstructor for creating a connection to the database.\nThis object has a `connect` method that returns a `Session` object. It takes a number of parameters which are database dependent.\n\n### Globals\n\n`api_level`\n\nString constant stating the supported DB API level.\n\nCurrently, only the strings _\"1.0\"_.\n\n`CONNECTION`\n\n_Connection_ object global variable.\n\n`SESSION`\n\n_Session_ object global variable.\n\n### Exceptions\n\n`Error`\n\nException that is the base class of all other error exceptions. You can use this to catch all errors with one single except statement.\n\n`UnknownError`\n\nException raised when an unspecified error occurred.\nIt must be a subclass of `Error`.\n\n`ConnectError`\n\nException raised for errors that are related to the database connection.\nIt must be a subclass of `Error`.\n\n`CloseError`\n\nException raised for errors that are related to the database close connection.\nIt must be a subclass of `Error`.\n\n`DatabaseError`\n\nException raised for errors that are related to the database, generally. \nIt must be a subclass of `Error`.\n\n`DatabaseCreationError`\n\nException raised for errors that are related to the creation of a database. \nIt must be a subclass of `DatabaseError`.\n\n`DatabaseDeletionError`\n\nException raised for errors that are related to the deletion of a database. \nIt must be a subclass of `DatabaseError`.\n\n`SessionError`\n\nException raised for errors that are related to the session, generally. \nIt must be a subclass of `Error`.\n\n`SessionInsertingError`\n\nException raised for errors that are related to the inserting data on a database session. \nIt must be a subclass of `SessionError`.\n\n`SessionUpdatingError`\n\nException raised for errors that are related to the updating data on a database session. \nIt must be a subclass of `SessionError`.\n\n`SessionDeletingError`\n\nException raised for errors that are related to the deletion data on a database session. \nIt must be a subclass of `SessionError`.\n\n`SessionClosingError`\n\nException raised for errors that are related to the closing database session. \nIt must be a subclass of `SessionError`.\n\n`SessionFindingError`\n\nException raised for errors that are related to the finding data on a database session. \nIt must be a subclass of `SessionError`.\n\n`SessionACLError`\n\nException raised for errors that are related to the grant or revoke permission on a database. \nIt must be a subclass of `SessionError`.\n\n`SelectorError`\n\nException raised for errors that are related to the selectors in general.\nIt must be a subclass of `Error`.\n\n`SelectorAttributeError`\n\nException raised for errors that are related to the selectors attribute. \nIt must be a subclass of `SelectorError`.\n\nThis is the exception inheritance layout:\n\n```\nException\n|__Error\n   |__UnknownError\n   |__ConnectError\n   |__CloseError\n   |__DatabaseError\n   |  |__DatabaseCreationError\n   |  |__DatabaseDeletionError\n   |__SessionError\n   |  |__SessionInsertingError\n   |  |__SessionUpdatingError\n   |  |__SessionDeletingError\n   |  |__SessionClosingError\n   |  |__SessionFindingError\n   |  |__SessionACLError\n   |__SelectorError\n      |__SelectorAttributeError\n```\n\n### Connection Objects\n\n`Connection` objects should respond to the following methods.\n\n#### Connection attributes\n\n`.connected`\n\nThis read-only attribute contains a boolean value.\n\n#### Connection methods\n\n`.close(parameters...)`\n\nClosing the connection now.\n\n`.connect(parameters...)`\n\nConnecting to database with the arguments when object has been instantiated and create a Session object to database.\n\n`.create_database(parameters...)`\n\nCreating a single database with position and keyword arguments.\n\n`.has_database(parameters...)`\n\nChecking if exists a single database with position and keyword arguments.\n\n`.delete_database(parameters...)`\n\nDeleting of a single database with position and keyword arguments.\n\n`.databases(parameters...)`\n\nList all databases.\n\n`.show_database(parameters...)`\n\nShow an information of a specific database\n\n### Session Objects\n\n`Session` objects should respond to the following methods.\n\n\u003e ATTENTION: Session object it will come instantiated if the `connection` value contains a compliant API Connection object. `database` value is optional.\n\n#### Session attributes\n\n`.connection`\n\nThis read-only attribute contains the _connection_ object or other object to serve connection (like sockets).\n\n`.description`\n\nThis read-only attribute contains the session parameters (can be string, list or dictionary).\n\n`.item_count`\n\nThis read-only attribute contains the number of object returned of an operations.\n\n`.database`\n\nThis read-only attribute contains the name of database in current session.\n\n`.acl`\n\nThis read-only attribute contains the _Access Control List_ in the current session.\n\n`.indexes`\n\nThis read-only attribute contains the name of indexes of the current database.\n\n\n#### Session methods\n\n`.get(parameters...)`\n\nGetting one or more data on specific database with position and keyword arguments.\n\n`.insert(parameters...)`\n\nInserting one data on specific database with position and keyword arguments.\n\n`.insert_many(parameters...)`\n\nInserting one or more data on specific database with position and keyword arguments.\n\n`.update(parameters...)`\n\nUpdating one existing data on specific database with position and keyword arguments.\n\n`.update_many(parameters...)`\n\nUpdating one or more existing data on specific database with position and keyword arguments.\n\n`.delete(parameters...)`\n\nDeleting one existing data on specific database with position and keyword arguments.\n\n`.close(parameters...)`\n\nClosing the session and connection now.\n\n`.find(parameters...)`\n\nFinding data on specific database with string selector or `Selector` object with position and keyword arguments.\n\n`.grant(parameters...)`\n\nGranting ACL on specific database with position and keyword arguments.\n\n`.revoke(parameters...)`\n\nRevoking ACL on specific database with position and keyword arguments.\n\n`.new_user(parameters...)`\n\nCreating new normal or admin user. \n\n`.set_user(parameters...)`\n\nModifying exists user or reset password.\n\n`.delete_user(parameters...)`\n\nDeleting exists user.\n\n`.add_index(parameters...)`\n\nAdding a new index to database.\n\n`.delete_index(parameters...)`\n\nDeleting exists index to database.\n\n`.call(batch, parameters...)`\n\nCalling a batch object to execute one or more statement.\n\n### Selector Objects\n\n`Selector` objects should respond to the following methods.\n\n#### Selector attributes\n\n`.selector`\n\nThis read/write attribute represents the _selector_ key/value than you want search.\n\n`.fields`\n\nThis read/write attribute represents the _fields_ key that returned from find operations. \n\n`.partition`\n\nThis read/write attribute represents the name of _partition/collection_ in a database.\n\n`.condition`\n\nThis read/write attribute represents other _condition_ to apply a selectors.\n\n`.order`\n\nThis read/write attribute represents _order_ returned from find operations.\n\n`.limit`\n\nThis read/write attribute represents _limit_ number of objects returned from find operations.\n\n#### Selector methods\n\n`.build(parameters...)`\n\nBuilding a _selector_ string in the dialect of a NOSQL language based on various property of the `Selector` object.\n\n### Response Objects\n\n`Response` objects should respond to the following attributes.\n\n\u003e `Response` objects is a species of an either-data type, because contains both success and error values\n\n#### Response attributes\n\n`.data`\n\nThis read-only attribute represents the effective data than returned (_Any_ object).\n\n`.code`\n\nThis read-only attribute represents a number code of error or success in an operation.\n\n`.header`\n\nThis read-only attribute represents a string information (header) of an operation.\n\n`.error`\n\nThis read-only attribute that throw an `Exception` if it has been set.\n\n`.dict`\n\nThis read-only attribute represents a dictionary transformation of Response object.\n\n#### Response methods\n\n`.throw()`\n\nRaise exception stored in _error_ property.\n\n### Batch Objects\n\n`Batch` objects should respond to the following methods.\n\n#### Batch attributes\n\n`.session`\n\nThis read/write attribute represents a `Session` object.\n\n`.batch`\n\nThis read/write attribute represents a _batch_ operation.\n\n#### Batch methods\n\n`.execute(parameters...)`\n\nExecuting a _batch_ operation with position and keyword arguments.\n\n\u003e Each database type may contain unique method names for the database type itself. For example, in the abstract class `nosqlapi.docdb.DocumentConnection` there is the `copy_database` method which is not present in the other types.\nThese characteristics distinguish the substantial differences between the four databases.\n\n## nosqlapi package\n\nThe package _nosqlapi_ is a collection of interface and utility class and functions for build your own NOSQL python package.\n\n### Test and installation\nTo test this package.\n\n```console\n$ git clone https://github.com/MatteoGuadrini/nosqlapi.git\n$ cd nosqlapi\n$ python -m unittest discover tests\n```\n\nInstead, to install package.\n\n```console\n$ pip install nosqlapi #from pypi\n\n$ git clone https://github.com/MatteoGuadrini/nosqlapi.git #from official repo\n$ cd nosqlapi\n$ python setup.py install\n```\n\n### Type of NoSql Database\n\nNoSql databases are of four types:\n\n- Key/Value database\n- Column database\n- Document database\n- Graph database\n\nFor each type of database, _nosqlapi_ offers standard interfaces, in order to unify as much as possible the names of methods and functions.\n\nFor an example, just look at the relevant package test files.\n\nLook as each test module has same class and each class has same method name.\nFor instance, look at **MyDBSession** class as inherit for each _nosqlapi_ type of abstract class:\n\n```console\n$ grep \"class MyDBSession\" tests/*\ntests/test_columndb.py:class MyDBSession(nosqlapi.columndb.ColumnSession):\ntests/test_docdb.py:class MyDBSession(nosqlapi.docdb.DocSession):\ntests/test_graphdb.py:class MyDBSession(nosqlapi.graphdb.GraphSession):\ntests/test_kvdb.py:class MyDBSession(nosqlapi.kvdb.KVSession):\n```\n\n### Key-Value database\nA _key–value_ database, or key–value store, is a data storage paradigm designed for storing, retrieving, and managing associative arrays, \nand a data structure more commonly known today as a dictionary or hash table. Dictionaries contain a collection of objects, or records, \nwhich in turn have many fields within them, each containing data. These records are stored and retrieved using a key that \nuniquely identifies the record, and is used to find the data within the database.\n\n```python\nimport nosqlapi.kvdb\n\n# Redis like database\nclass RedisConnection(nosqlapi.kvdb.KVConnection):...\nclass RedisSession(nosqlapi.kvdb.KVSession):...\nclass RedisResponse(nosqlapi.kvdb.KVResponse):...\nclass RedisBatch(nosqlapi.kvdb.KVBatch):...\nclass RedisSelector(nosqlapi.kvdb.KVSelector):...\n\n# Use Redis library\nconn = RedisConnection(host='server.local', username='admin', password='pass', database='db')\nsess = conn.connect()       # return RedisSession object\n# Create a new database\nconn.create_database('new_db')\n\n# CRUD operation\nC = sess.insert('key', 'value')         # Create\nR = sess.get('key')                     # Read\nU = sess.update('key', 'new_value')     # Update\nD = sess.delete('key')                  # Delete\n\nprint(R)                                    # {'key': 'value'}\nprint(type(R))                              # \u003cclass 'RedisResponse'\u003e\nprint(isinstance(R, nosqlapi.Response))     # True\n\n# Extended CRUD operations\nsess.insert_many({'key1': 'value1', 'Key2': 'value2'})\nsess.update_many({'key1': 'new_value1', 'Key2': 'new_value2'})\n\n# Complex select operation\nsel = RedisSelector(selector='key:value id:1 ttl:300', limit=2)\nsess.find(sel)\n\n# Batch operations\nop = 'SET hello \"Hello\"\\nSET mykey \"new\"\\nGET mykey\\nSET anotherkey \"will expire in a minute\" EX 60'\nbatch = RedisBatch(batch=op, session=sess)\nresp = batch.execute()\nprint(resp)            # ('OK', 'OK', {'mykey': 'new'}, 'OK')\nprint(type(resp))      # \u003cclass 'RedisResponse'\u003e\n\n```\n\n### Column database\nA _column-oriented_ DBMS or columnar DBMS is a database management system (DBMS) that stores data tables by column rather than by row. \nPractical use of a column store versus a row store differs little in the relational DBMS world. Both columnar and row databases \ncan use traditional database query languages like SQL to load data and perform queries. Both row and columnar databases can \nbecome the backbone in a system to serve data for common extract, transform, load (ETL) and data visualization tools. \nHowever, by storing data in columns rather than rows, the database can more precisely access the data it needs to answer \na query rather than scanning and discarding unwanted data in rows.\n\n```python\nimport nosqlapi.columndb\n\n# Cassandra like database\nclass CassandraConnection(nosqlapi.columndb.ColumnConnection):...\nclass CassandraSession(nosqlapi.columndb.ColumnSession):...\nclass CassandraResponse(nosqlapi.columndb.ColumnResponse):...\nclass CassandraBatch(nosqlapi.columndb.ColumnBatch):...\nclass CassandraSelector(nosqlapi.columndb.ColumnSelector):...\n\n# Use Cassandra library\nconn = CassandraConnection(host='server.local', username='admin', password='pass', database='db')\nsess = conn.connect()       # return CassandraSession object\n# Create a new database\nconn.create_database('new_db')\n\n# CRUD operation\nC = sess.insert(table='hitchhikers', columns=('id', 'name', 'age'), values=(1, 'Arthur', 42))            # Create\nR = sess.get(table='hitchhikers', columns=('id', 'name', 'age'))                                         # Read\nU = sess.update(table='hitchhikers', columns=('id', 'name', 'age'), values=(1, 'Arthur', 43))            # Update\nD = sess.delete(table='hitchhikers', conditions=[\"name='Arthur'\", 'age=43'])                             # Delete\n\nprint(R)                                    # [(1, 'Arthur', 42)]\nprint(type(R))                              # \u003cclass 'CassandraResponse'\u003e\nprint(isinstance(R, nosqlapi.Response))     # True\n\n# Extended CRUD operations\nsess.insert_many(table='hitchhikers', columns=('id', 'name', 'age'), values=[(1, 'Arthur', 42), (2, 'Arthur', 43)])\nsess.update_many(table='hitchhikers', columns=('id', 'name', 'age'), values=[(1, 'Arthur', 44), (2, 'Arthur', 45)])\n\n# Complex select operation\nsel = CassandraSelector()\n# Table\nsel.selector = 'hitchhikers'\n# Columns\nsel.fields = ['id', 'name', 'age']\nsess.find(sel)\n\n# Batch operations\nop = \"BEGIN BATCH\\nINSERT INTO hitchhikers (id, name, age)\\n VALUES (1, 'Arthur', 42)\\nIF NOT EXISTS;\\nAPPLY BATCH;\"\nbatch = CassandraBatch(batch=op, session=sess)\nresp = batch.execute()\nprint(resp)            # [(1, 'Arthur', 42)]\nprint(type(resp))      # \u003cclass 'CassandraResponse'\u003e\n\n```\n\n### Document database\nA _document-oriented_ database, or document store, is a computer program and data storage system designed for storing, \nretrieving and managing document-oriented information, also known as semi-structured data.\n\nDocument-oriented databases are one of the main categories of NoSQL databases, and the popularity of the term \n_\"document-oriented database\"_ has grown with the use of the term NoSQL itself. Graph databases are similar, but add another \nlayer, the relationship, which allows them to link documents for rapid traversal.\n\n```python\nimport nosqlapi.docdb\n\n# MongoDB like database\nclass MongoConnection(nosqlapi.docdb.DocConnection):...\nclass MongoSession(nosqlapi.docdb.DocSession):...\nclass MongoResponse(nosqlapi.docdb.DocResponse):...\nclass MongoBatch(nosqlapi.docdb.DocBatch):...\nclass MongoSelector(nosqlapi.docdb.DocSelector):...\n\n# Use MongoDB library\nconn = MongoConnection(host='server.local', username='admin', password='pass')\nsess = conn.connect()       # return MongoSession object\n# Create a new database\nconn.create_database('new_db')\n\n# CRUD operation\nC = sess.insert(path='db/doc1', doc={\"_id\": \"5099803df3f4948bd2f98391\", \"name\": \"Arthur\", \"age\": 42})           # Create\nR = sess.get(path='db/doc1')                                                                                    # Read\nU = sess.update(path='db/doc1', doc={\"_id\": \"5099803df3f4948bd2f98391\", \"name\": \"Arthur\", \"age\": 43}, rev=2)    # Update\nD = sess.delete(path='db/doc1', rev=2)                                                                          # Delete\n\nprint(R)                                    # {\"_id\": \"5099803df3f4948bd2f98391\", \"rev\"= 2, \"name\": \"Arthur\", \"age\": 42}\nprint(type(R))                              # \u003cclass 'MongoResponse'\u003e\nprint(isinstance(R, nosqlapi.Response))     # True\n\n# Extended CRUD operations\nsess.insert_many(database='db', docs=[{\"_id\": \"5099803df3f4948bd2f98391\", \"name\": \"Arthur\", \"age\": 42}, \n                 {\"_id\": \"5099803df3f4948bd2f98392\", \"name\": \"Arthur\", \"age\": 43}])\nsess.update_many(database='db', docs=[{\"_id\": \"5099803df3f4948bd2f98391\", \"name\": \"Arthur\", \"age\": 42, \"rev\": 2}, \n                 {\"_id\": \"5099803df3f4948bd2f98392\", \"name\": \"Arthur\", \"age\": 43, \"rev\": 2}])\n\n# Complex select operation\nsel = MongoSelector(selector={\"name\": \"Arthur\"}, fields=['_id', 'name', 'age'], limit=2)\nsess.find(sel)\n\n# Batch operations\nop = [{\"_id\": \"5099803df3f4948bd2f98391\", \"name\": \"Arthur\", \"age\": 42}, {\"_id\": \"5099803df3f4948bd2f98392\", \"name\": \"Arthur\", \"age\": 43}]\nbatch = MongoBatch(batch=op, session=sess)\nresp = batch.execute(crud='insert')\nprint(resp)            # [{\"_id\": \"5099803df3f4948bd2f98391\", \"rev\"= 2, \"name\": \"Arthur\", \"age\": 42}, {\"_id\": \"5099803df3f4948bd2f98392\", \"rev\"= 2, \"name\": \"Arthur\", \"age\": 43}]\nprint(type(resp))      # \u003cclass 'MongoResponse'\u003e\n\n```\n\n### Graph database\n_Graph_ databases are a type of NoSQL database, created to address the limitations of relational databases. \nWhile the graph model explicitly lays out the dependencies between nodes of data, the relational model and other \nNoSQL database models link the data by implicit connections. In other words, relationships are a first-class citizen \nin a graph database and can be labelled, directed, and given properties. This is compared to relational approaches where \nthese relationships are implied and must be reified at run-time. Graph databases are similar to 1970s network model \ndatabases in that both represent general graphs, but network-model databases operate at a lower level of abstraction \nand lack easy traversal over a chain of edges.\n\n```python\nimport nosqlapi.graphdb\n\n# Neo4j like database\nclass Neo4jConnection(nosqlapi.graphdb.GraphConnection):...\nclass Neo4jSession(nosqlapi.graphdb.GraphSession):...\nclass Neo4jResponse(nosqlapi.graphdb.GraphResponse):...\nclass Neo4jBatch(nosqlapi.graphdb.GraphBatch):...\nclass Neo4jSelector(nosqlapi.graphdb.GraphSelector):...\n\n# Use Neo4j library\nconn = Neo4jConnection(host='server.local', username='admin', password='pass', database='db')\nsess = conn.connect()       # return Neo4jSession object\n# Create a new database\nconn.create_database('new_db')\n\n# CRUD operation\nC = sess.insert(node='n:Person', properties={'name': 'Arthur', 'age': 42})           # Create\nR = sess.get(node='n:Person')                                                        # Read\nU = sess.update(node='n:Person', properties={'name': 'Arthur', 'age': 42})           # Update\nD = sess.delete(node='n:Person')                                                     # Delete\n\nprint(R)                                    # {'n.name': 'Arthur', 'n.age': 42}\nprint(type(R))                              # \u003cclass 'Neo4jResponse'\u003e\nprint(isinstance(R, nosqlapi.Response))     # True\n\n# Extended CRUD operations\nsess.insert_many(nodes=['matteo:Person', 'arthur:Person'], properties=[{'name': 'Matteo', 'age': 35}, \n                                                                       {'name': 'Arthur', 'age': 42}])\nsess.update_many(nodes=['matteo:Person', 'arthur:Person'], properties=[{'name': 'Matteo', 'age': 35}, \n                                                                       {'name': 'Arthur', 'age': 42}])\nsess.link(node='arthur:Person{name: \"Arthur\"}', to_link='book:hitchhikers', relationship=':ACT_IN')\nsess.detach(node='arthur:Person{name: \"Arthur\"}')\n\n# Complex select operation\nsel = Neo4jSelector(selector='people:Person', fields=['name', 'age'], condition='people.age\u003e=35', order='age', limit=2)\nsess.find(sel)\n\n# Batch operations\nop = \"MATCH (p:Person {name: 'Arhur'})-[rel:ACT_IN]-(:Book {name: 'hitchhikers'})\\nSET rel.startYear = date({year: 2018})\\nRETURN p\"\nbatch = Neo4jBatch(batch=op, session=sess)\nresp = batch.execute()\nprint(resp)            # {'p.name': 'Arhur', 'p.age': 42}\nprint(type(resp))      # \u003cclass 'Neo4jResponse'\u003e\n\n```\n\n### ODM (Object-Data Mapping)\nFor each type of NOSQL database there is an _ODM (Object-relational mapping)_ module that contains classes and functions relating to the mapping of \nobjects and/or operations concerning the specific database _CRUD operation_.\n\nIn the `nosqlapi.common.odm` module there are also classes that represent the data types of databases.\n\n```pycon\n\u003e\u003e\u003e import nosqlapi.common.odm\n\u003e\u003e\u003e [t for t in dir(nosqlapi.common.odm) if not t.startswith('__')]\n['Array', 'Ascii', 'Blob', 'Boolean', 'Counter', 'Date', 'Dc', 'Decimal', 'Double', 'Duration', 'Float', 'Inet', 'Int', \n'List', 'Map', 'Null', 'SmallInt', 'Text', 'Time', 'Timestamp', 'Uuid', 'Varchar']\n```\n\n### Utilities\nThe package also comes with useful classes and functions to help migrate a library to these APIs. \nBesides, these there are also some utilities for end users.\n\n#### api decorator\n\n```python\nimport nosqlapi\nfrom pymongo import Connection\n\n# This decorator allows you to map existing method names to API compliant methods.\n@nosqlapi.api(database_names='databases', drop_database='delete_database', close_cursor='close')\nclass ApiConnection(Connection):\n    pass\n\nconn = ApiConnection('localhost', 27017, 'test_database')\nhasattr(conn, 'databases')      # True\nconn.databases()                # (test_database, 'db1', 'db2')\n```\n\n#### Manager session\n\n```python\nimport nosqlapi\nfrom neo4j import Neo4jConnection\nfrom mymongo import MongoConnection\n\n# Create manager for session API\nman = nosqlapi.Manager(Neo4jConnection(host='server.local', username='admin', password='pass', database='db'))\nprint(type(man))        # \u003cclass 'Manager'\u003e\nprint(man)              # database=db, description=('db', 'online')\n\n# CRUD operation\nC = man.insert(node='n:Person', properties={'name': 'Arthur', 'age': 42})           # Create\nR = man.get(node='n:Person')                                                        # Read\nU = man.update(node='n:Person', properties={'name': 'Arthur', 'age': 42})           # Update\nD = man.delete(node='n:Person')                                                     # Delete\n\n# Change session\nman.change(MongoConnection(host='server.local', username='admin', password='pass', database='db'))\nC = man.insert(path='db/doc1', doc={\"_id\": \"5099803df3f4948bd2f98391\", \"name\": \"Arthur\", \"age\": 42})           # Create\nR = man.get(path='db/doc1')                                                                                    # Read\nU = man.update(path='db/doc1', doc={\"_id\": \"5099803df3f4948bd2f98391\", \"name\": \"Arthur\", \"age\": 43}, rev=2)    # Update\nD = man.delete(path='db/doc1', rev=2)                                                                          # Delete\n```\n\n## Open source\n_nosqlapi_ is an open source project. Any contribute, It's welcome.\n\n**A great thanks**.\n\nFor donations, press this\n\nFor me\n\n[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.me/guos)\n\nFor [Telethon](http://www.telethon.it/)\n\nThe Telethon Foundation is a non-profit organization recognized by the Ministry of University and Scientific and Technological Research.\nThey were born in 1990 to respond to the appeal of patients suffering from rare diseases.\nCome today, we are organized to dare to listen to them and answers, every day of the year.\n\n\u003ca href=\"https://www.telethon.it/sostienici/dona-ora\"\u003e \u003cimg src=\"https://www.telethon.it/dev/_nuxt/img/c6d474e.svg\" alt=\"Telethon\" title=\"Telethon\" width=\"200\" height=\"104\" /\u003e \u003c/a\u003e\n\n[Adopt the future](https://www.ioadottoilfuturo.it/)\n\n\n## Treeware  \n\nThis package is [Treeware](https://treeware.earth). If you use it in production, \nthen we ask that you [**buy the world a tree**](https://plant.treeware.earth/matteoguadrini/nosqlapi) to thank us for our work. \nBy contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.\n\n[![Treeware](https://img.shields.io/badge/dynamic/json?color=brightgreen\u0026label=Treeware\u0026query=%24.total\u0026url=https%3A%2F%2Fpublic.offset.earth%2Fusers%2Ftreeware%2Ftrees)](https://treeware.earth)\n\n\n## Acknowledgments\n\nThanks to Mark Lutz for writing the _Learning Python_ and _Programming Python_ books that make up my python foundation.\n\nThanks to Kenneth Reitz and Tanya Schlusser for writing the _The Hitchhiker’s Guide to Python_ books.\n\nThanks to Dane Hillard for writing the _Practices of the Python Pro_ books.\n\nSpecial thanks go to my wife, who understood the hours of absence for this development. \nThanks to my children, for the daily inspiration they give me and to make me realize, that life must be simple.\n\nThanks Python!","funding_links":["https://www.paypal.me/guos"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatteoguadrini%2Fnosqlapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatteoguadrini%2Fnosqlapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatteoguadrini%2Fnosqlapi/lists"}