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

SQLAlchemy #9

Open
CraftedCat opened this issue Jan 6, 2023 · 1 comment
Open

SQLAlchemy #9

CraftedCat opened this issue Jan 6, 2023 · 1 comment

Comments

@CraftedCat
Copy link

CraftedCat commented Jan 6, 2023

Hi, guys!

When i try upgrade db via flask-migrate plugin, got error:

Starting in NORMAL Mode Corporation. All rights reserved.   
[2023-01-06 18:07:30,559] INFO in __init__: DEBUG            = True
[2023-01-06 18:07:30,559] INFO in __init__: Instance Path    = C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\instance
[2023-01-06 18:07:30,559] INFO in __init__: Root Path        = C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\apps
[2023-01-06 18:07:30,560] INFO in __init__: Templates Path   = templates
[2023-01-06 18:07:30,560] INFO in __init__: Static Path      = C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\apps\static
[2023-01-06 18:07:30,560] INFO in __init__: FLASK_ENV        = development
[2023-01-06 18:07:30,560] INFO in __init__: Page Compression = FALSE
[2023-01-06 18:07:30,560] INFO in __init__: DBMS             = sqlite:///C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\apps\db.sqlite3
[2023-01-06 18:07:30,560] INFO in __init__: ASSETS_ROOT      = /static/assets
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> bc8c8fd7a55d, empty message
Traceback (most recent call last):
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1802, in _execute_context
    self.dialect.do_execute(
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\sqlalchemy\engine\default.py", line 732, in do_execute    
    cursor.execute(statement, parameters)
sqlite3.OperationalError: table sqlite_sequence may not be dropped

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

Traceback (most recent call last):
  File "C:\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\Scripts\flask.exe\__main__.py", line 7, in <module>
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\flask\cli.py", line 994, in main
    cli.main(args=sys.argv[1:])
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\flask\cli.py", line 600, in main
    return super().main(*args, **kwargs)
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\click\decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\flask\cli.py", line 444, in decorator
    return __ctx.invoke(f, *args, **kwargs)
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\flask_migrate\cli.py", line 149, in upgrade
    _upgrade(directory, revision, sql, tag, x_arg)
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\flask_migrate\__init__.py", line 98, in wrapped
    f(*args, **kwargs)
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\flask_migrate\__init__.py", line 185, in upgrade
    command.upgrade(config, revision, sql=sql, tag=tag)
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\alembic\command.py", line 378, in upgrade
    script.run_env()
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\alembic\script\base.py", line 569, in run_env
    util.load_python_file(self.dir, "env.py")
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\alembic\util\pyfiles.py", line 94, in load_python_file
    module = load_module_py(module_id, path)
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\alembic\util\pyfiles.py", line 110, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "migrations\env.py", line 91, in <module>
    run_migrations_online()
  File "migrations\env.py", line 85, in run_migrations_online
    context.run_migrations()
  File "<string>", line 8, in run_migrations
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\alembic\runtime\environment.py", line 865, in run_migrations
    self.get_context().run_migrations(**kw)
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\alembic\runtime\migration.py", line 624, in run_migrations
    step.migration_fn(**kw)
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\migrations\versions\bc8c8fd7a55d_.py", line 21, in upgrade
    op.drop_table('sqlite_sequence')
  File "<string>", line 8, in drop_table
  File "<string>", line 3, in drop_table
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\alembic\operations\ops.py", line 1355, in drop_table
    operations.invoke(op)
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\alembic\operations\base.py", line 401, in invoke
    return fn(self, operation)
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\alembic\operations\toimpl.py", line 79, in drop_table
    operations.impl.drop_table(
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\alembic\ddl\impl.py", line 377, in drop_table
    self._exec(schema.DropTable(table))
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\alembic\ddl\impl.py", line 193, in _exec
    return conn.execute(  # type: ignore[call-overload]
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1289, in execute
    return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\sqlalchemy\sql\ddl.py", line 80, in _execute_on_connection
    return connection._execute_ddl(
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1381, in _execute_ddl
    ret = self._execute_context(
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1845, in _execute_context
    self._handle_dbapi_exception(
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\sqlalchemy\engine\base.py", line 2026, in _handle_dbapi_exception
    util.raise_(
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\sqlalchemy\util\compat.py", line 207, in raise_
    raise exception
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\sqlalchemy\engine\base.py", line 1802, in _execute_context
    self.dialect.do_execute(
  File "C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark\venv\lib\site-packages\sqlalchemy\engine\default.py", line 732, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) table sqlite_sequence may not be dropped
[SQL:
DROP TABLE sqlite_sequence]
(Background on this error at: https://sqlalche.me/e/14/e3q8)
(venv) PS C:\Users\gdvvl\PycharmProjects\flask-atlantis-dark> 
@app-generator
Copy link
Owner

Hello @CraftedCat

Thank you for using our products.
The migration on top of SQLite is known as being buggy and is not recommended.

To avoid such issues, you can:

  • delete sqlite file, update the database, and all tables are recreated.
    • this is not a migration, is basically a hard reset.
  • Migrate and use a DMBS like MySql, MariaDB, or PostgreSQL.

Feel free to ask for support using the coordinates listed on the official page:
https://appseed.us/support/

In all cases, let us know your progress.
🚀🚀

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

2 participants