I am developing a project in Flask
and using SQLAlchemy
as ORM
I have a User
model as
class User(UserMixin, db.Model):
__tablename__ = 'users'
# noinspection PyShadowingBuiltins
uuid = Column('uuid', GUID(), default=uuid.uuid4, primary_key=True,
unique=True)
email = Column('email', String, nullable=False, unique=True)
_password = Column('password', String, nullable=False)
created_on = Column('created_on', sa.types.DateTime(timezone=True),
default=datetime.utcnow())
last_login = Column('last_login', sa.types.DateTime(timezone=True),
onupdate=datetime.utcnow())
- I create a migration script using Alembic.
- My database of choice is
PostgreSQL
but to test my models I preferred to useSQLite
to make tests faster - Problem came in when there are some types in
PostgreSQL
and not inSQLite
, in this caseUUID
- When I run migration on
sqlite://
, it gives me error
AttributeError: 'module' object has no attribute 'GUID'
Question
- How can I keep my schema with GUID
and run in-memory tests with SQLite? seems like SQLite
doesn't have anything like it
- What are some ways people run tests faster(in-memory) when their database is PostgreSQL