Skip to main content

Install

MyNLQ’s source code hosted on GitHub.

git clone https://github.com/livinter/MyNQL.git
python setup.py install

or just

pip install MyNQL

Teach the Network

For example if a customer make a purchase of a product you assume a relation between customer.id and product.id, so you connect them. Optional you can specify a distance between nodes, to represent how close the nodes are related.

  • connect - connect two nodes

  • delete - delete a connection

Nodes are created automatically when you do the connection, and removed if they do not have any more connections. So do not worry about them.

Ask the Network

Now you can query all kinds of relations, not only the once you taught. With select you specify a starting point, like customer.id and specify the category where you like to know its closes relation.

  • select - gives you the best related nodes from a specified category

The searching query takes into account all the different routes up to a radius you specify.

Example

Lets imagine we already have a table customer

Id

Name

101

jose

…

102

maria

…

103

juan

…

and you want to teach the network about recent purchases.

from MyNQL import MyNQL
mynql = MyNQL('store')

mynql.connect('customer.juan', 'product.jeans')
mynql.connect('customer.juan',  'product.socks')
mynql.connect('customer.maria', 'product.socks')

If the column Name is unique you can use it as a key, otherwise you would need column Id, and your code would look like this:

mynql.connect("customer.103', 'product.12')

Now you can ask questions from other points of view. You always specify a starting point, and the category where you want to know the best matches:

>>> mynql.select('customer.maria', 'product')
['socks', 'jeans']

Maria is more connected to socks, as she has a direct connection, but also a bit to jeans as there exist an indirect connection through Juan.

>>> mynql.select('product.jeans', 'product')
['socks']

Any combination is valid. For example you can ask about how one product is related to other.

Backend

Storage is done in memory, but if you want to use MySQL, SQLite or PostgreSQL as a backend take a look at test/pee_example.py. This will keep a copy of all updates in your database.

Release files for MyNQL 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for MyNQL 0.2.1
File Size Uploaded
MyNQL-0.2.1.tar.gz 7.9 kB Details

Release files / MyNQL-0.2.1.tar.gz

Download URL MyNQL-0.2.1.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
fcd40e61d0c302ed238985a705c0d1df7ea17d6c001eb21b35936342ce98be2d
BLAKE2b-256 checksum
How to use checksums
3c965e45ac8e2b29613d5a8e416a20d4788301a15141de93e6da2ba98a6aa331
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.1 This release

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page