Skip to content

Instantly share code, notes, and snippets.

View rodrigoestevao's full-sized avatar

Rodrigo Estevao Rodrigues rodrigoestevao

View GitHub Profile
@yesthesoup
yesthesoup / test_migrations.py
Created September 24, 2020 21:57
Unit testing Flask and Alembic database migrations with pytest
from alembic.config import Config
from alembic.script import ScriptDirectory
from flask_migrate import downgrade, upgrade, stamp
from flask_project import create_app
from flask_project.config import TestingConfig
from flask_project.database import db # db = flask_sqlalchemy.SQLAlchemy()
# in conftest.py
@pytest.fixture
@SuryaSankar
SuryaSankar / M2M_Association_SQLalchemy.py
Last active September 25, 2023 07:30
An example of a many to many relation via Association Object in SQLAlchemy
import sqlalchemy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import sessionmaker, relationship, backref
from sqlalchemy.ext.associationproxy import association_proxy
import uuid
engine = sqlalchemy.create_engine('sqlite:///:memory:')
Base = declarative_base()
@inexorabletash
inexorabletash / ansi_colors
Created February 20, 2014 20:30
Bash color utilities
#!/usr/bin/env bash
# Usage:
# echo -e "... $(text-style style ...) ..."
# echo -e "... $(text-reset) ..."
# echo -e "... $(text-color r g b) ..."
# echo -e "... $(background-color r g b) ..."
#
# Where:
# styles: