Debian Codegraph @

README.md

raw symbols SCIP
1 RDFLib-SQLAlchemy
2 =================
3
4 A SQLAlchemy-backed, formula-aware RDFLib Store. It stores its triples
5 in the following partitions:
6
7 - Asserted non rdf:type statements.
8 - Asserted rdf:type statements (in a table which models Class membership). The motivation for this partition is primarily query speed and scalability as most graphs will always have more rdf:type statements than others.
9 - All Quoted statements.
10
11 In addition, it persists namespace mappings in a separate table. Table names are prefixed `kb_{identifier_hash}`, where `identifier_hash` is the first ten characters of the SHA1 hash of the given identifier.
12
13 Back-end persistence
14 --------------------
15
16 Back-end persistence is provided by SQLAlchemy.
17
18 Tested dialects are:
19
20 - SQLite, using the built-in Python driver
21 - MySQL, using the MySQLdb-python driver or, for Python 3, mysql-connector
22 - PostgreSQL, using the psycopg2 driver or the pg8000 driver.
23
24 pysqlite: https://pypi.python.org/pypi/pysqlite
25
26 MySQLdb-python: https://pypi.python.org/pypi/MySQL-python
27
28 mysql-connector: http://dev.mysql.com/doc/connector-python/en/connector-python.html
29
30 psycopg2: https://pypi.python.org/pypi/psycopg2
31
32 pg8000: https://pypi.python.org/pypi/pg8000
33
34 Development
35 ===========
36 ***Note: Currently, rdflib-sqlalchemy is in maintenance mode. That means the
37 current maintainer (@mwatts15) will do what he can to keep the package working
38 for existing use-cases, but new features will not be added and newer versions
39 of SQLAlchemy will not be supported. If you have an interest in further
40 development of rdflib-sqlalchemy, please get in touch with @mwatts15 or [core
41 RDFLib project developers][rdflib-contact].***
42
43 [rdflib-contact]: https://rdflib.readthedocs.io/en/stable/#further-help-contact
44
45 Github repository: https://github.com/RDFLib/rdflib-sqlalchemy
46
47 Continuous integration: https://travis-ci.org/RDFLib/rdflib-sqlalchemy/
48
49 ![Travis CI](https://travis-ci.org/RDFLib/rdflib-sqlalchemy.png?branch=develop)
50 ![PyPI](https://img.shields.io/pypi/v/rdflib-sqlalchemy.svg)
51 ![PyPI](https://img.shields.io/pypi/status/rdflib-sqlalchemy.svg)
52 ![PyPI](https://img.shields.io/pypi/dw/rdflib-sqlalchemy.svg)
53
54 ![PyPI](https://img.shields.io/pypi/pyversions/rdflib-sqlalchemy.svg)
55 ![PyPI](https://img.shields.io/pypi/l/rdflib-sqlalchemy.svg)
56 ![PyPI](https://img.shields.io/pypi/wheel/rdflib-sqlalchemy.svg)
57 ![PyPI](https://img.shields.io/pypi/format/rdflib-sqlalchemy.svg)
58
59
60 An illustrative unit test:
61 ==========================
62
63 ```python
64
65 import unittest
66 from rdflib import plugin, Graph, Literal, URIRef
67 from rdflib.store import Store
68
69
70 class SQLASQLiteGraphTestCase(unittest.TestCase):
71 ident = URIRef("rdflib_test")
72 uri = Literal("sqlite://")
73
74 def setUp(self):
75 self.graph = Graph("SQLAlchemy", identifier=self.ident)
76 self.graph.open(self.uri, create=True)
77
78 def tearDown(self):
79 self.graph.destroy(self.uri)
80 try:
81 self.graph.close()
82 except:
83 pass
84
85 def test01(self):
86 self.assert_(self.graph is not None)
87 print(self.graph)
88
89 if __name__ == '__main__':
90 unittest.main()
91 ```
92
93 Running the tests
94 =================
95 `pytest` is supported as a test runner, typically called via `tox`. Select the
96 SQL back-end by setting a `DB` environment variable. Select the database
97 connection by setting the `DBURI` variable. With `tox`, you can also specify
98 the Python version.
99
100 Using pytest::
101
102 DB='pgsql' DBURI='postgresql+psycopg2://user:password@host/dbname' pytest
103
104 Using tox::
105
106 DB='pgsql' DBURI='postgresql+psycopg2://user:password@host/dbname' tox -e py310
107
108 DB variants are 'pgsql', 'mysql' and 'sqlite'. Except in the case of SQLite,
109 you'll need to create the database independently, before execution of the test.
110
111 Sample DBURI values::
112
113 dburi = Literal("mysql://username:password@hostname:port/database-name?other-parameter")
114 dburi = Literal("mysql+mysqldb://user:password@hostname:port/database?charset=utf8")
115 dburi = Literal('postgresql+psycopg2://user:password@hostname:port/database')
116 dburi = Literal('postgresql+pg8000://user:password@hostname:port/database')
117 dburi = Literal('sqlite:////absolute/path/to/foo.db')
118 dburi = Literal("sqlite:///%(here)s/development.sqlite" % {"here": os.getcwd()})
119 dburi = Literal('sqlite://') # In-memory