Skip to content

Instantly share code, notes, and snippets.

@kanchansrivastava
kanchansrivastava / sqlalchemy_example.py
Created February 22, 2017 05:42 — forked from podhmo/sqlalchemy_example.py
sqlalchemy query example.
import sqlalchemy as sa
import sqlalchemy.orm as orm
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy.orm import scoped_session, sessionmaker
DBSession = scoped_session(sessionmaker())
class BaseMixin(object):
query = DBSession.query_property()
id = sa.Column(sa.Integer, primary_key=True)
@kanchansrivastava
kanchansrivastava / create_test_db.py
Created February 13, 2017 10:05 — forked from sprin/create_test_db.py
A demo of creating a new database via SQL Alchemy. This module takes the form of a nosetest with three steps: - Set up the new database. - Create a table in the new database. - Teardown the new database.
"""
A demo of creating a new database via SQL Alchemy.
Under MIT License from sprin (https://gist.github.com/sprin/5846464/)
This module takes the form of a nosetest with three steps:
- Set up the new database.
- Create a table in the new database.
- Teardown the new database.
"""
def fetch_import_statement():
my_imports = """
import ast
import dill as pickle
import re
import pymongo
from datetime import datetime
import proton.blueprint