RDFLib / rdflib-sqlalchemy

RDFLib store using SQLAlchemy dbapi as back-end
Other
148 stars 34 forks source link

Problem when loading data into sqlite #33

Closed tzatzosm closed 5 years ago

tzatzosm commented 7 years ago

I am currently trying to load from a sample file from yago ontology (n3). This one for example.

But i am getting this error.

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: kb_20f710cd41_namespace_binds [SQL: 'SELECT kb_20f710cd41_namespace_binds.prefix \nFROM kb_20f710cd41_namespace_binds \nWHERE kb_20f710cd41_namespace_binds.uri = ?'] [parameters: ('http://www.w3.org/XML/1998/namespace',)]

The complete stacktrace for this is

Traceback (most recent call last):
  File "/Users/max/.virtualenvs/twitter-trending/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/Users/max/.virtualenvs/twitter-trending/lib/python3.5/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: no such table: kb_20f710cd41_namespace_binds

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/max/.virtualenvs/twitter-trending/lib/python3.5/site-packages/rdflib/graph.py", line 1041, in parse
    parser.parse(source, self, **args)
  File "/Users/max/.virtualenvs/twitter-trending/lib/python3.5/site-packages/rdflib/plugins/parsers/notation3.py", line 1897, in parse
    conj_graph.namespace_manager = graph.namespace_manager
  File "/Users/max/.virtualenvs/twitter-trending/lib/python3.5/site-packages/rdflib/graph.py", line 330, in _get_namespace_manager
    self.__namespace_manager = NamespaceManager(self)
  File "/Users/max/.virtualenvs/twitter-trending/lib/python3.5/site-packages/rdflib/namespace.py", line 281, in __init__
    self.bind("xml", "http://www.w3.org/XML/1998/namespace")
  File "/Users/max/.virtualenvs/twitter-trending/lib/python3.5/site-packages/rdflib/namespace.py", line 394, in bind
    bound_prefix = self.store.prefix(namespace)
  File "/Users/max/.virtualenvs/twitter-trending/lib/python3.5/site-packages/rdflib_sqlalchemy/store.py", line 659, in prefix
    res = connection.execute(s)
  File "/Users/max/.virtualenvs/twitter-trending/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 945, in execute
    return meth(self, multiparams, params)
  File "/Users/max/.virtualenvs/twitter-trending/lib/python3.5/site-packages/sqlalchemy/sql/elements.py", line 263, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/Users/max/.virtualenvs/twitter-trending/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1053, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/Users/max/.virtualenvs/twitter-trending/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
    context)
  File "/Users/max/.virtualenvs/twitter-trending/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1393, in _handle_dbapi_exception
    exc_info
  File "/Users/max/.virtualenvs/twitter-trending/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/Users/max/.virtualenvs/twitter-trending/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
    raise value.with_traceback(tb)
  File "/Users/max/.virtualenvs/twitter-trending/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/Users/max/.virtualenvs/twitter-trending/lib/python3.5/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: kb_20f710cd41_namespace_binds [SQL: 'SELECT kb_20f710cd41_namespace_binds.prefix \nFROM kb_20f710cd41_namespace_binds \nWHERE kb_20f710cd41_namespace_binds.uri = ?'] [parameters: ('http://www.w3.org/XML/1998/namespace',)]

The code that produces this error is

from rdflib import Graph
from rdflib_sqlalchemy.store import SQLAlchemy
from sqlalchemy import create_engine

engine = create_engine('sqlite:///foo.db')

store = SQLAlchemy(engine=engine)
graph = Graph(store)

graph.load('yago/sample.rdf', format='n3')
mwatts15 commented 5 years ago

Cannot reproduce.