Skip to content

Instantly share code, notes, and snippets.

Yuri Ohno yuriwoof

  • Tokyo
View GitHub Profile
View app.py
from __future__ import absolute_import
from celery_flask import make_celery
from flask import Flask
from config import Config
config = Config()
flask_app = Flask(__name__)
flask_app.config.update(
CELERY_BROKER_URL=config.CELERY_BROKER_URL
View config.py
class Config(object):
CELERY_BROKER_URL = 'pyamqp://vagrant:vagrant@localhost/vagrant'
View celery_flask.py
from celery import Celery
def make_celery(app):
celery = Celery(app.import_name, broker=app.config['CELERY_BROKER_URL'])
celery.conf.update(app.config)
TaskBase = celery.Task
class ContextTask(TaskBase):
abstract = True
def __call__(self, *args, **kwargs):
@yuriwoof
yuriwoof / default_controller.py
Created Dec 31, 2016
petstore/default_controller.py
View default_controller.py
import logging
import datetime
from connexion import NoContent
from db import db_session
from models import Pet
from sqlalchemy import or_
@yuriwoof
yuriwoof / db.py
Created Dec 31, 2016
petshop/db.py
View db.py
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('sqlite:///petstore.db', convert_unicode=True)
db_session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,
bind=engine))
Base = declarative_base()
@yuriwoof
yuriwoof / model.py
Created Dec 31, 2016
petshop/model.py
View model.py
from sqlalchemy import Column, DateTime, Integer, String
from db import db_session, Base
class Pet(Base):
__tablename__ = 'pets'
id = Column(Integer, primary_key=True)
name = Column(String(100))
tag = Column(String(20))
created = Column(DateTime())
View Excel2DB.java
package jp.hermesian.excel2db;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.dbunit.database.DatabaseConnection;
You can’t perform that action at this time.