Skip to content

Commit 085ec0f

Browse files
0 parents  commit 085ec0f

27 files changed

+519
-0
lines changed

.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# general things to ignore
2+
build/
3+
dist/
4+
*.egg-info/
5+
*.egg
6+
*.py[cod]
7+
__pycache__/
8+
*.so
9+
*~
10+
11+
# due to using tox and pytest
12+
.tox
13+
.cache
14+
.pytest_cache

LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
Copyright (c) Denis Papathanasiou
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a
5+
copy of this software and associated documentation files (the "Software"),
6+
to deal in the Software without restriction, including without limitation
7+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
and/or sell copies of the Software, and to permit persons to whom the
9+
Software is furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included
12+
in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+
OTHER DEALINGS IN THE SOFTWARE.

MANIFEST.in

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include pyproject.toml
2+
3+
include *.md
4+
include LICENSE.txt
5+
include setup.py
6+
7+
recursive-include sql *

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# About
2+
3+
This is the meta repository for packaging the [simple-graph](https://github.com/dpapathanasiou/simple-graph/blob/main/python) implementation in [Python](https://www.python.org/) for distribution in [PyPI](https://pypi.org/).

pyproject.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[build-system]
2+
requires = [
3+
"setuptools>=42",
4+
"wheel"
5+
]
6+
build-backend = "setuptools.build_meta"

setup.cfg

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[metadata]
2+
name = simple-graph-sqlite
3+
version = 2.0.0
4+
author = Denis Papathanasiou
5+
description = A simple graph database in SQLite
6+
long_description = file: README.md
7+
long_description_content_type = text/markdown
8+
url = https://github.com/dpapathanasiou/simple-graph
9+
project_urls =
10+
Bug Tracker = https://github.com/dpapathanasiou/simple-graph/issues
11+
12+
[options]
13+
package_dir =
14+
= src
15+
packages = find:
16+
python_requires = >=3.6
17+
18+
[options.packages.find]
19+
where = src

setup.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from setuptools import setup, find_packages
2+
import pathlib
3+
4+
here = pathlib.Path(__file__).parent.resolve()
5+
sql = (here / "sql")
6+
7+
long_description = (here / 'README.md').read_text(encoding='utf-8')
8+
9+
setup(
10+
name='simple-graph-sqlite',
11+
version='2.0.0',
12+
description='A simple graph database in SQLite',
13+
long_description=long_description,
14+
long_description_content_type='text/markdown',
15+
url='https://github.com/dpapathanasiou/simple-graph',
16+
author='Denis Papathanasiou',
17+
package_dir={'': 'src'},
18+
packages=find_packages(where='src'),
19+
python_requires='>=3.6, <4',
20+
install_requires=['graphviz'],
21+
extras_require={
22+
'test': ['pytest'],
23+
},
24+
data_files=[('sql', [f'sql/{file.name}' for file in sql.glob('*.sql')])],
25+
project_urls={
26+
'Bug Reports': 'https://github.com/dpapathanasiou/simple-graph/issues',
27+
'Source': 'https://github.com/dpapathanasiou/simple-graph/tree/main/python',
28+
},
29+
)

sql/delete-edge.sql

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DELETE FROM edges WHERE source = ? OR target = ?

sql/delete-node.sql

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DELETE FROM nodes WHERE id = ?

sql/insert-edge.sql

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INSERT INTO edges VALUES(?, ?, json(?))

sql/insert-node.sql

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INSERT INTO nodes VALUES(json(?))

sql/schema.sql

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
CREATE TABLE IF NOT EXISTS nodes (
2+
body TEXT,
3+
id TEXT GENERATED ALWAYS AS (json_extract(body, '$.id')) VIRTUAL NOT NULL UNIQUE
4+
);
5+
6+
CREATE INDEX IF NOT EXISTS id_idx ON nodes(id);
7+
8+
CREATE TABLE IF NOT EXISTS edges (
9+
source TEXT,
10+
target TEXT,
11+
properties TEXT,
12+
FOREIGN KEY(source) REFERENCES nodes(id),
13+
FOREIGN KEY(target) REFERENCES nodes(id)
14+
);
15+
16+
CREATE INDEX IF NOT EXISTS source_idx ON edges(source);
17+
CREATE INDEX IF NOT EXISTS target_idx ON edges(target);

sql/search-edges-inbound.sql

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT * FROM edges WHERE source = ?

sql/search-edges-outbound.sql

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT * FROM edges WHERE target = ?

sql/search-edges.sql

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SELECT * FROM edges WHERE source = ?
2+
UNION
3+
SELECT * FROM edges WHERE target = ?

sql/search-node-by-id.sql

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT body FROM nodes WHERE json_extract(body, '$.id') = ?

sql/search-node.sql

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT body FROM nodes WHERE

sql/traverse-inbound.sql

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
WITH RECURSIVE traverse(id) AS (
2+
SELECT ?
3+
UNION
4+
SELECT source FROM edges JOIN traverse ON target = id
5+
) SELECT id FROM traverse;

sql/traverse-outbound.sql

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
WITH RECURSIVE traverse(id) AS (
2+
SELECT ?
3+
UNION
4+
SELECT target FROM edges JOIN traverse ON source = id
5+
) SELECT id FROM traverse;

sql/traverse.sql

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
WITH RECURSIVE traverse(id) AS (
2+
SELECT ?
3+
UNION
4+
SELECT source FROM edges JOIN traverse ON target = id
5+
UNION
6+
SELECT target FROM edges JOIN traverse ON source = id
7+
) SELECT id FROM traverse;

sql/update-node.sql

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
UPDATE nodes SET body = json(?) WHERE id = ?

src/simple_graph_sqlite/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)