Ejemplo n.º 1
0
 def setUp(self) -> None:
     self.app = create_app("testing")
     self.client = self.app.test_client()
     self.app.app_context().push()
     db.create_all()
     self.book_data = json.dumps({
         "title": "Single Book",
         "author": "Book author",
         "price": 200
     })
     self.headers = {"Content-Type": "application/json"}
Ejemplo n.º 2
0
 def run(self):
     if self.args.producer_class_name:
         self.p.run_by_class_name(self.args.producer_class_name)
     elif self.args.consumer_class_name:
         self.s.run_by_class_name(self.args.consumer_class_name)
     elif self.args.run_all_producer:
         self.p.run_all()
     elif self.args.migrate:
         db.create_all()
     else:
         self.s.start()
         self.p.start()
Ejemplo n.º 3
0
#! /usr/bin/env python2
# encoding: utf8

import py_path
from utils.db import create_all, _database

if __name__ == "__main__":
    if not raw_input(
            "Are you shure you want to create database?[yes/no]: ") == 'yes':
        exit(0)

    print "Creating database with default alias in global settings..."

    ## Init session
    session = _database._get_db_session()

    ## Import and create all models:
    create_all(dirpath='models')
Ejemplo n.º 4
0
def db_init(allergo_file, recipes_file):
    ''' initialize a db '''
    db.create_all()
    fill_allergies(allergo_file)
    fill_recipes(recipes_file)
Ejemplo n.º 5
0
from sqlalchemy import create_engine, exc
import tables

from utils import db
"""
This simple script takes care of the MySQL set-up.
"""
engine = create_engine("mysql://localhost/mysql")

conn = engine.connect()
conn.execute("COMMIT")
try:
    conn.execute("CREATE DATABASE sobbingrabbit")
except exc.ProgrammingError:
    print("exists")
conn.close()

db.create_all()
Ejemplo n.º 6
0
    """
    Add tzinfo if not available
    Assuming the column always use UTC timezone
    """
    impl = TIMESTAMP(timezone=True)

    def process_result_value(self, value, dialect):
        if value and not value.tzinfo:
            value = value.replace(tzinfo=timezone.utc)
        return value


class RSSNotification(db.Base):
    __tablename__ = 'rss_notifications'
    id = Column(Integer, primary_key=True)
    user_id = Column(String, nullable=False, index=True)
    chat_id = Column(String)
    rss_url = Column(Text, nullable=False)
    last_item_date = Column(TimeStamp)


class TradingPortfolio(db.Base):
    __tablename__ = 'trading_portfolios'
    id = Column(Integer, primary_key=True)
    user_id = Column(String, nullable=False, index=True)
    chat_id = Column(String)
    data = Column(JSON, nullable=True)


db.create_all(db.Base, db.engine)
Ejemplo n.º 7
0
def clear_db():
    db.session.commit()
    db.drop_all()
    db.create_all()
Ejemplo n.º 8
0
def initdb():
    """Creates all database tables."""
    db.create_all()