Skip to content

Instantly share code, notes, and snippets.

@AkiraKito
AkiraKito / gist:4064958
Created November 13, 2012 09:56
Make the query only for the hours and minutes (datetime.time object) using SQLAlchemy
# -*- coding: utf-8 -*-
from sqlalchemy import Column, Time, Integer, Boolean, create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
# SQL statements and expressions API
# cf. http://docs.sqlalchemy.org/en/rel_0_7/core/expression_api.html
from sqlalchemy import and_, extract
@AkiraKito
AkiraKito / upload_mypackage_to_pypi
Created November 11, 2012 11:48
How to upload my (new) package to PyPI
setup.py のあるディレクトリで、とりあえずバージョンを確認:
$ python setup.py --version
PyPIにソース配布物をアップロードする:
$ python setup.py sdist upload
@AkiraKito
AkiraKito / polymorphic_model.py
Created March 8, 2012 21:40
Polymorphic model with SQLAlchemy
# -*- coding: utf-8 -*-
from sqlalchemy import Column, String, Integer, ForeignKey, create_engine
from sqlalchemy.orm import sessionmaker, relation
from sqlalchemy.ext import declarative
engine = create_engine('sqlite:///:memory:')
Session = sessionmaker(bind=engine)
session = Session()