Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

home page example fails #402

Open
matecsaj opened this issue Nov 16, 2022 · 0 comments
Open

home page example fails #402

matecsaj opened this issue Nov 16, 2022 · 0 comments

Comments

@matecsaj
Copy link

Code source: https://dataset.readthedocs.io/en/latest/

import dataset

db = dataset.connect('sqlite:///:memory:')

table = db['sometable']
table.insert(dict(name='John Doe', age=37))
table.insert(dict(name='Jane Doe', age=34, gender='female'))

john = table.find_one(name='John Doe')

Result:

/Users/matecsaj/Documents/Projects/nugget_spiders/venv/bin/python /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py --multiprocess --qt-support=auto --client 127.0.0.1 --port 53910 --file /Users/matecsaj/Library/Application Support/JetBrains/PyCharm2022.2/scratches/scratch.py 
Traceback (most recent call last):
  File "/Users/matecsaj/Documents/Projects/nugget_spiders/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context
    self.dialect.do_execute(
  File "/Users/matecsaj/Documents/Projects/nugget_spiders/venv/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: no such table: sometable

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

Traceback (most recent call last):
  File "/Users/matecsaj/Documents/Projects/nugget_spiders/venv/lib/python3.10/site-packages/dataset/table.py", line 356, in _sync_table
    self.db.op.add_column(self.name, column, self.db.schema)
  File "<string>", line 3, in add_column
  File "/Users/matecsaj/Documents/Projects/nugget_spiders/venv/lib/python3.10/site-packages/alembic/operations/ops.py", line 2047, in add_column
    return operations.invoke(op)
  File "/Users/matecsaj/Documents/Projects/nugget_spiders/venv/lib/python3.10/site-packages/alembic/operations/base.py", line 399, in invoke
    return fn(self, operation)
  File "/Users/matecsaj/Documents/Projects/nugget_spiders/venv/lib/python3.10/site-packages/alembic/operations/toimpl.py", line 154, in add_column
    operations.impl.add_column(table_name, column, schema=schema, **kw)
  File "/Users/matecsaj/Documents/Projects/nugget_spiders/venv/lib/python3.10/site-packages/alembic/ddl/impl.py", line 322, in add_column
    self._exec(base.AddColumn(table_name, column, schema=schema))
  File "/Users/matecsaj/Documents/Projects/nugget_spiders/venv/lib/python3.10/site-packages/alembic/ddl/impl.py", line 195, in _exec
    return conn.execute(construct, multiparams)
  File "/Users/matecsaj/Documents/Projects/nugget_spiders/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1380, in execute
    return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
  File "/Users/matecsaj/Documents/Projects/nugget_spiders/venv/lib/python3.10/site-packages/sqlalchemy/sql/ddl.py", line 80, in _execute_on_connection
    return connection._execute_ddl(
  File "/Users/matecsaj/Documents/Projects/nugget_spiders/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1472, in _execute_ddl
    ret = self._execute_context(
  File "/Users/matecsaj/Documents/Projects/nugget_spiders/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1943, in _execute_context
    self._handle_dbapi_exception(
  File "/Users/matecsaj/Documents/Projects/nugget_spiders/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2124, in _handle_dbapi_exception
    util.raise_(
  File "/Users/matecsaj/Documents/Projects/nugget_spiders/venv/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 210, in raise_
    raise exception
  File "/Users/matecsaj/Documents/Projects/nugget_spiders/venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context
    self.dialect.do_execute(
  File "/Users/matecsaj/Documents/Projects/nugget_spiders/venv/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: sometable
[SQL: ALTER TABLE sometable ADD COLUMN name TEXT]
(Background on this error at: https://sqlalche.me/e/14/e3q8)

Process finished with exit code 1

When I substitute the following line, it works fine.

db = dataset.connect('sqlite:///mydatabase.db')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant