Exemplo n.º 1
0
def create_db():
    db.session.rollback()
    db.drop_all()
    db.create_all()
    if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
        api.create(SQLALCHEMY_MIGRATE_REPO, 'database_repository')
        api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
    else:
        api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))
Exemplo n.º 2
0
def create_db():
    db.session.rollback()
    db.drop_all()
    db.create_all()
    if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
        api.create(SQLALCHEMY_MIGRATE_REPO, 'database_repository')
        api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
    else:
        api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO,
                            api.version(SQLALCHEMY_MIGRATE_REPO))
Exemplo n.º 3
0
 def setUp(self):
     """called before  any test"""
     #create tables
     self.client = self.app.test_client()
     self.product = {
         'name': 'testproduct',
         'price': 56.0,
         'category': 'ipods'
     }
     db.create_all()
Exemplo n.º 4
0
    def setUp(self):
        """
        Sets up the default configurations, and in this case creates
        the database to be used
        """
        with self.app.test_client():
            db.session.close()
            db.drop_all()
            db.create_all()

        self.populate_db()
Exemplo n.º 5
0
def create_db(test_app):
    try:
        db.create_all(app=test_app)
    except:
        sqlalchemy_utils.create_database(TestConfig.SQLALCHEMY_DATABASE_URI)
        db.create_all(app=test_app)

    yield db
    #db.session.close()
    db.session.remove()
    db.drop_all(app=test_app)
Exemplo n.º 6
0
def home():
    db.create_all()
    page = request.args.get('page', 1, type=int)
    events = Event.query.filter().order_by(Event.title).paginate(page=page,
                                                                 per_page=3)
    epoch = datetime(1970, 1, 1, 0, 0, 0)
    return render_template('home.html',
                           title='Home',
                           events=events,
                           current_time=datetime.utcnow(),
                           epoch=epoch,
                           sidebar=True)
Exemplo n.º 7
0
    def setUp(self):
        """
        Will be called before every test
        """
        db.create_all()

        admin = Employee(username="******", password="******", is_admin=True)

        employee = Employee(username="******", password="******")

        db.session.add(admin)
        db.session.add(employee)
        db.session.commit()
Exemplo n.º 8
0
def init_database():
    # Create the database and the database table
    db.create_all()

    # Insert user data
    user1 = User(username='******', plaintext_password='******')
    user2 = User(email='anotheruser', plaintext_password='******')
    db.session.add(user1)
    db.session.add(user2)

    # Commit the changes for the users
    db.session.commit()

    yield db  # this is where the testing happens!

    db.drop_all()
Exemplo n.º 9
0
def create_populate_db():
	from models import Account, Milestone, Timeline

	# Creation de la database

	db.drop_all()
	db.create_all()

	# Creation des comptes

	livretA = Account('Livret A', '3900')
	livretJeune = Account('Livret Jeune', '1600')
	db.session.add(livretA)
	db.session.add(livretJeune)

	june = Timeline(datetime.datetime.strptime('01 06 2015', "%d %m %Y").date(), '350')
	july = Timeline(datetime.datetime.strptime('01 07 2015', "%d %m %Y").date(), '330')
	august = Timeline(datetime.datetime.strptime('01 08 2015', "%d %m %Y").date(), '1000')
	september = Timeline(datetime.datetime.strptime('01 09 2015', "%d %m %Y").date(), '1500')
	october = Timeline(datetime.datetime.strptime('01 10 2015', "%d %m %Y").date(), '2500')
	november = Timeline(datetime.datetime.strptime('01 11 2015', "%d %m %Y").date(), '3100')
	december = Timeline(datetime.datetime.strptime('01 12 2015', "%d %m %Y").date(), '5500')
	db.session.add(june)
	db.session.add(july)
	db.session.add(august)
	db.session.add(september)
	db.session.add(october)
	db.session.add(november)
	db.session.add(december)

	# Creation des milestones

	mille = Milestone('1000 !!', '1000')
	cinqmille = Milestone('5000 !!', '5000')
	dixmille = Milestone('10 000 !!', '10000')
	vingtmille = Milestone('20 000 !!', '20000')
	cinquantemille = Milestone('50 000 !!', '50000')
	centmille = Milestone('100 000 !!', '100000')
	db.session.add(mille)
	db.session.add(cinqmille)
	db.session.add(dixmille)
	db.session.add(vingtmille)
	db.session.add(cinquantemille)
	db.session.add(centmille)

	#commit
	db.session.commit()
Exemplo n.º 10
0
def create_admin(admin, password):
    db.create_all()

    admin_name = Nickname.query.first()
    if admin_name is not None:
        click.echo('updating...')
        admin_name.admin = admin
        admin_name.set_password(password)

    else:
        click.echo('creating admin...')
        admin_name = Nickname(admin=admin, name='houshanyun')
        admin_name.set_password(password)
        db.session.add(admin_name)

    db.session.commit()
    click.echo('Done')
Exemplo n.º 11
0
    def setUp(self):
        app.config['TESTING'] = True
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
        app.check_auth = Mock(return_value=False)

        self.app = app.test_client()
        db.create_all()
        self.app = app.test_client()
        self.non_existing_user = '******'
        self.creds = ('service2', 'simple')
        self.owner = 'foobar'
        self.resources = ['321aa00a', '3432aaaa', 'fobara']
        u = User(id=self.owner)
        for i in self.resources:
            u.resources.append(Resource(id=i))
        db.session.add(u)
        db.session.commit()
Exemplo n.º 12
0
def db_handle(db):
    db.drop_all()
    db.create_all()
Exemplo n.º 13
0
def create_db():
    """Creates the db tables."""
    db.create_all(bind=None)
Exemplo n.º 14
0
#!/usr/bin/env python3

from myapp import app, db

db.create_all(app=app)
app.run(debug=True)
Exemplo n.º 15
0
    __tablename__='oplog'
    id=db.Column(db.Integer,primary_key=True)
    # admin_id=db.Column(db.Integer,db.ForeignKey("admin.id"))
    admin_id=db.Column(db.Integer)
    ip=db.Column(db.String(100))
    reason=db.Column(db.String(600))
    addtime=db.Column(db.DATETIME,index=True,default=datetime.datetime.now)

    def __repr__(self):
        return "<oplog %s>"%self.id
    def add_log(log):
        db.session.add(log)
        db.session.commit()

if __name__=='__main__':
    # pass
    # 创建表
    db.drop_all(User)
    db.create_all(User)
    # from werkzeug.security import generate_password_hash
    # role=Admin(
    #
    #     name='李不搭',
    # pwd=generate_password_hash('zslswmz'),
    # is_super=1,
    #
    # )
    # db.session.add(role)
    # db.session.commit()
    # #
Exemplo n.º 16
0
    def setUp(self):

        db.create_all()
Exemplo n.º 17
0
def create_tables():
    db.create_all()
Exemplo n.º 18
0
def create_all_db(app):
    with app.app_context():
        db.create_all()
Exemplo n.º 19
0
def init_db():
    """ Initialize the database."""
    db.drop_all()
    db.create_all()
    create_admin_users()
Exemplo n.º 20
0
def create_database():
    print "begin create database"
    db.create_all()
    return "OK"
Exemplo n.º 21
0
def schema_update():
    db.create_all()
    print('you had update all tables')
Exemplo n.º 22
0
#!/usr/bin/env python
from myapp import create_app, db
from myapp.models import User

if __name__ == '__main__':
	app = create_app('development')
	with app.app_context():
		db.create_all()
	app.run()
Exemplo n.º 23
0
def init_db():
    db.drop_all()
    db.create_all()
Exemplo n.º 24
0
def initdb():
    db.create_all()
    download_initial_nbp_rates_and_update_db()
Exemplo n.º 25
0
def create_db():
    db.create_all()
Exemplo n.º 26
0
#!/usr/bin/env python
from migrate.versioning import api
from config import SQLALCHEMY_DATABASE_URI
from config import SQLALCHEMY_MIGRATE_REPO
from myapp import db
import os.path
# Create the database, based on models
db.create_all()
# Version control directory
if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
    api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
    api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
else:
    api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO,
                        api.version(SQLALCHEMY_MIGRATE_REPO))
Exemplo n.º 27
0
 def setUp(self):
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
     db.create_all()
Exemplo n.º 28
0
def initdb(drop):
    if drop:
        db.drop_all()
    db.create_all()
    click.echo('重置資料庫')
Exemplo n.º 29
0
 def setUp(self):
     app.config['TESTING'] = True
     app.app_context()
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test1.db'
     self.app = app.test_client()
     db.create_all()
Exemplo n.º 30
0
def client():
    with app.app_context():
        db.create_all()
    app.testing = True
    app.debug = True
    return app.test_client()
Exemplo n.º 31
0
 def setUp(self):
     self.app = self.create_app()
     db.create_all()
Exemplo n.º 32
0
def create_all_db(app):
    with app.app_context():
        db.create_all()
Exemplo n.º 33
0
    def setUp(self):

        db.create_all()
Exemplo n.º 34
0
def initdb():
    db.create_all()
Exemplo n.º 35
0
 def setUp(self):
     self.app = create_app(TestConfig)
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
Exemplo n.º 36
0
def create_db():
    db.create_all()
Exemplo n.º 37
0
def deploy():
	from flask.ext.migrate import upgrade
	from myapp.models import Role, User

	db.create_all()
	Role.insert_roles()