我想测试一个在CI管道中有数据库的Flask应用程序。我想用SQLite替换数据库进行测试,因为SQLite不需要任何设置。
但是,这些表具有模式,并且SQLite不支持该模式。有没有其他轻量级数据库支持模式?最好也是基于文件的文件或不需要初始设置的内存中的文件?
最小示例
import sqlalchemy as sa
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
SQLALCHEMY_DATABASE_URI = "sqlite:///foobar.db"
Base = declarative_base()
user = sa.Table(
"users", Base.metadata, sa.Column("id", sa.Integer, primary_key=True), schema="foobar"
)
engine = create_engine(SQLALCHEMY_DATABASE_URI, echo=True)
Base.metadata.create_all(engine)给出
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unknown database "foobar"
[SQL: PRAGMA "foobar".table_info("users")]https://stackoverflow.com/questions/64004162
复制相似问题