diff --git a/alembic.ini b/alembic.ini index 563c6d9..0bc9b86 100644 --- a/alembic.ini +++ b/alembic.ini @@ -84,7 +84,7 @@ path_separator = os # database URL. This is consumed by the user-maintained env.py script only. # other means of configuring database URLs may be customized within the env.py # file. -sqlalchemy.url = driver://user:pass@localhost/dbname +sqlalchemy.url = sqlite+aiosqlite:///bookmarks.db [post_write_hooks] diff --git a/migrations/env.py b/migrations/env.py index 9f2d519..b9ac505 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -1,11 +1,13 @@ import asyncio from logging.config import fileConfig +from alembic import context from sqlalchemy import pool from sqlalchemy.engine import Connection from sqlalchemy.ext.asyncio import async_engine_from_config +from sqlmodel import SQLModel -from alembic import context +# from app.models import Bookmark # this is the Alembic Config object, which provides # access to the values within the .ini file in use. @@ -20,7 +22,7 @@ if config.config_file_name is not None: # for 'autogenerate' support # from myapp import mymodel # target_metadata = mymodel.Base.metadata -target_metadata = None +target_metadata = SQLModel.metadata # other values from the config, defined by the needs of env.py, # can be acquired: @@ -40,12 +42,12 @@ def run_migrations_offline() -> None: script output. """ - url = config.get_main_option("sqlalchemy.url") + url = config.get_main_option('sqlalchemy.url') context.configure( url=url, target_metadata=target_metadata, literal_binds=True, - dialect_opts={"paramstyle": "named"}, + dialect_opts={'paramstyle': 'named'}, ) with context.begin_transaction(): @@ -64,10 +66,9 @@ async def run_async_migrations() -> None: and associate a connection with the context. """ - connectable = async_engine_from_config( config.get_section(config.config_ini_section, {}), - prefix="sqlalchemy.", + prefix='sqlalchemy.', poolclass=pool.NullPool, ) @@ -79,7 +80,6 @@ async def run_async_migrations() -> None: def run_migrations_online() -> None: """Run migrations in 'online' mode.""" - asyncio.run(run_async_migrations()) diff --git a/requirements.in b/requirements.in index 2e21251..4e915a1 100644 --- a/requirements.in +++ b/requirements.in @@ -2,6 +2,7 @@ fastapi[all] sqlmodel alembic +aiosqlite # Fetch title etc from links beautifulsoup4