Esempio 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"}
Esempio 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()
Esempio 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')
Esempio n. 4
0
def db_init(allergo_file, recipes_file):
    ''' initialize a db '''
    db.create_all()
    fill_allergies(allergo_file)
    fill_recipes(recipes_file)
Esempio 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()
Esempio 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)
Esempio n. 7
0
def clear_db():
    db.session.commit()
    db.drop_all()
    db.create_all()
Esempio n. 8
0
def initdb():
    """Creates all database tables."""
    db.create_all()