This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ============================================================================= | |
# routes.py | |
# ============================================================================= | |
@bp.route('/add_child_product', methods=['POST']) | |
def add_child_product(): | |
""" | |
Handle form validation. If form is invalid, re-render form with validation | |
errors. If the form is valid, update product spec table, close modal and | |
reset form. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy import (create_engine, and_, Column, Integer, String, | |
ForeignKey, Float) | |
from sqlalchemy.orm import relationship, sessionmaker | |
from sqlalchemy.ext.declarative import declarative_base | |
import random | |
import pandas as pd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, render_template_string | |
from flask_sqlalchemy import SQLAlchemy | |
app = Flask('__name__') | |
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql+psycopg2://postgres:######@127.0.0.1/so_test' | |
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False | |
app.config['SESSION_TYPE'] = 'sqlalchemy' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SECRET_KEY = '2a057dd2f0844f5a928578032c5b9955' | |
DB_URL = 'postgresql+psycopg2://postgres:######@127.0.0.1/so_test' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The contents of beatroute/src/beatroute/config.py | |
import __main__ | |
import json | |
import os | |
import sqlite3 | |
import uuid | |
from pathlib import Path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import datetime as dt | |
import pandas as pd | |
df = pd.DataFrame({'date': ['2021-01-02', '2021-01-03', '2021-01-04', | |
'2021-01-01', '2021-01-03', '2021-01-04', | |
'2021-01-01', '2021-01-02', '2021-01-04', | |
'2021-01-01', '2021-01-02', '2021-01-03'], | |
'plant': [1, 1, 1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
import pandas as pd | |
conn = sqlite3.connect(':memory:') | |
c = conn.cursor() | |
c.execute(""" | |
CREATE TABLE food_labour ( | |
name TEXT, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# src/ex_machina/database.py | |
import click | |
import os | |
from alembic import command | |
from alembic.config import Config as AlembicConfig | |
from alembic.util import AutogenerateDiffsDetected | |
from sqlalchemy import create_engine, MetaData | |
from sqlalchemy.orm import scoped_session, sessionmaker |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# File deliberately empty, but gist won't allow it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from string import ascii_letters | |
import timeit | |
import numpy as np | |
import pandas as pd | |
letters = [ | |
"".join(np.random.choice(list(ascii_letters), 10, replace=True)) | |
for x in range(1000000) |