コード例 #1
0
ファイル: main.py プロジェクト: openspork/cust_queue
def initialize_db():
    db.connect()  #connect to db
    #print 'opened db!'
    db.create_tables([Location, Customer],
                     safe=True)  #create tables if not present
    build_queues()  #build the queue
    atexit.register(closedb)  #register exit handler to close db on exit
コード例 #2
0
ファイル: models.py プロジェクト: gkrnours/plume
def init_db(database=None):
    if not database:
        database = app.config["DATABASE"]
    db.init(database)
    db.connect()
    db.create_tables([Author, Content])
    Author.create(id=1, name="author")
    db.close()
コード例 #3
0
def createtables_db():
    # Connect to our database.
    db.connect()
    
    # Create the tables.
    db.create_tables([Contribution, File])

    print "Created tables"
コード例 #4
0
ファイル: manage.py プロジェクト: miracledan/flask-skeleton
def deploy():
    """Run deployment tasks."""
    tables = []

    db.drop_tables(tables)
    db.create_tables(tables)

    from app.core.models import mock_all_models
    mock_all_models()
コード例 #5
0
def migrate():
    database_module = importlib.import_module('database')
    if should_refresh:
        db.drop_tables([
            database_module.__dict__[table]
            for table in reversed(database_module.__all__)
        ])
    db.create_tables(
        [database_module.__dict__[table] for table in database_module.__all__])

    logger.info('tables migrated successfuly')
コード例 #6
0
ファイル: commands.py プロジェクト: scmmishra/nimo
def create_demo_data():
    with db:
        print("Creating DB")
        db.create_tables([Project, PageView])

    uuid = get_uuid()
    project_name = "getnimo.app"

    print("Creating Project:")
    print("\tProject Name: {0}".format(project_name))
    print("\tProject ID: {0}".format(uuid))

    project = Project.create(uuid=uuid, name=project_name)
    project.save()

    d1 = datetime.strptime('1/1/2019 1:30 PM', '%m/%d/%Y %I:%M %p')
    d2 = datetime.strptime('6/1/2020 4:50 AM', '%m/%d/%Y %I:%M %p')

    routes = [
        '/', '/', '/', '/', '/blog/v8', '/projects/frappe', '/projects/charts',
        '/projects/nimo', '/blog/hello'
    ]
    referrer = [
        'https://twitter.com', 'https://duckduckgo.com', 'https://github.com',
        'https://google.com', 'https://google.com', 'https://google.com'
    ]
    broswer = [
        'Chrome', 'Chrome', 'Chrome', 'Chrome', 'Firefox', 'Opera', 'Safari'
    ]
    timezones = [
        'Asia/Kolkata', 'Asia/Kolkata', 'Asia/Kolkata', 'Europe/London',
        'America/Chicago', 'America/New_York', 'Pacific/Honolulu',
        'America/Denver', 'Europe/Istanbul'
    ]

    print("Creating 15000 Entries")

    for ii in range(15000):
        rdate = random_date(d1, d2)
        pageview = PageView.create(
            project_id=uuid,
            creation=rdate,
            modified=rdate + timedelta(seconds=random.randint(100, 900)),
            path=random.choice(routes),
            is_unique=random.choice([True, True, False]),
            referrer=random.choice(referrer),
            timezone=random.choice(timezones),
            browser_name=random.choice(broswer),
            browser_version='71')
        pageview.save()

    print("Demo Data Created")
    print("Go Make Some Noise!")
コード例 #7
0
def create_tables():
    # Create table for each model if it does not exist.
    # Use the underlying peewee database object instead of the
    # flask-peewee database wrapper:
    tables = [
        Doctor,
        DoctorSpecialty,
        Graduate,
        GraduateRecord,
        Proxy,
        Vehicle,
        RRLL,
        TelephoneLine,
    ]
    db.create_tables(tables, safe=True)
コード例 #8
0
def init_db():
    '''Initial database'''
    db.connect()

    print('Creating tables ...')
    db.create_tables(tables)
    print('Tables have been created.')

    print('Writing default configurations ...')
    Config.create(name='site_name', value=app.config['DEFAULT_SITE_NAME'])
    Config.create(name='site_url', value=app.config['DEFAULT_SITE_URL'])
    Config.create(name='count_topic',
                  value=app.config['DEFAULT_TOPICS_PER_PAGE'])
    Config.create(name='count_post',
                  value=app.config['DEFAULT_POSTS_PER_PAGE'])
    Config.create(name='count_list_item',
                  value=app.config['DEFAULT_LIST_ITEM_PER_PAGE'])
    #   Config.create(name='count_subpost', value=app.config['DEFAULT_SUBPOSTS_PER_PAGE'])
    print('Default configurations have been written into database.')

    db.close()
コード例 #9
0
import sys
from app import app, db
from os.path import abspath, dirname, join
base_path = dirname(abspath(__file__))
sys.path.insert(1, sys.path[0])
sys.path.insert(1, join(base_path, 'lib'))
sys.path.insert(1, join(base_path, 'models'))
import views
from tag import Tag  # a Peewee DB model

if __name__ == '__main__':
    db.create_tables([Tag], safe=True)
    app.run()
コード例 #10
0
ファイル: run.py プロジェクト: katmai1/qportfolio
 def __init__(self, args):
     self.app = QApplication([])
     self.debug = args['--debug']
     signal(SIGINT, SIG_DFL)
     create_tables()
コード例 #11
0
# main.py
from app import db
from app import app as application
from models import Track, Statistic, Tag
import views

if __name__ == '__main__':
    db.connect()
    db.create_tables([Track, Statistic, Tag])
    db.close()
    application.run()
コード例 #12
0
def create_tables():
    with db:
        db.create_tables(MODELS)
コード例 #13
0
def init_db():
    db.create_tables([Role, User, Post, Point, RoleUser])
    init_data()
    logger.info("Init data successful.")
    return JsonResult()
コード例 #14
0
ファイル: run.py プロジェクト: tonko-cupic/Linker
from app import app, db
from routes import *
from models import *

if __name__ == '__main__':
    db.create_tables([User, Group, Link, UserToGroup], safe=True)
    app.run()
コード例 #15
0
ファイル: main.py プロジェクト: longcw/hust_classroom
# coding :utf-8

from app import myapp, db
from models import ClassRoom
import view

db.create_tables([ClassRoom], safe=True)
if __name__ == '__main__':
    myapp.run('0.0.0.0')
コード例 #16
0
def initialize():
    """Create tables."""
    db.connect()
    db.create_tables([Category, Project, Post, Media, User], safe=True)
    db.close()
コード例 #17
0
 def init_db_command():
     # with db:
     db.create_tables(models_list)
     click.echo('Initialized the database.')
コード例 #18
0
from pony.orm import db_session
from app import db
from models.User import User, UserSchema
from models.Landmark import Landmark
from models.Story import Story

# We delete all tables in our database
db.drop_all_tables(with_all_data=True)
db.create_tables() # We create tables in our database


with db_session():
    schema = UserSchema()
    alikurtulus = User(
        username='******',
        email='*****@*****.**',
        password_hash=schema.generate_hash('sda')
    )

    Story(
     cityname='Lisbon',
     title='Lisbon was great holiday',
     user=alikurtulus,
     description="Lisbon is, in my opinion, one of the best cities to spend a weekend and a perfect place to experience one of Europe’s smaller capitals – but don’t let the word ‘smaller’ fool you! Lisbon packs a hefty punch with great places to see, eat and places to totally ‘let your hair down’…",
     date='12.08.2018',
     image='https://handluggageonly.co.uk/wp-content/uploads/2015/09/DSC02292.jpg'
    )
    Story(
     cityname='Madrid',
     title='Madrid was dream holiday',
     user=alikurtulus,
コード例 #19
0
ファイル: run.py プロジェクト: Catgroove/dotaninja
def initialize():
    db.connect()
    db.create_tables([Match, MatchPlayer, Player], safe=True)
    db.close()
コード例 #20
0
from app import app, db
from models import Link, DailyStats
import handlers

if __name__ == '__main__':
    db.create_tables([Link, DailyStats])
    app.run(host="0.0.0.0")
コード例 #21
0
ファイル: run.py プロジェクト: kevinyu/bearded-octo-robot
def setup_tables():
    import models
    model_list = reversed(p.sort_models_topologically(models.BaseModel.__subclasses__()))
    db.create_tables(model_list, safe=True)
コード例 #22
0
ファイル: main.py プロジェクト: rostislav444/involve_test
def create_tables():
    with db:
        db.create_tables([Order])
コード例 #23
0
def create_tables():
    db.create_tables([Business, Customer, Appointment, Conversation])
    business = Business.create(name="Math Tutoring Inc.", phone="+19158000459")
コード例 #24
0
def draw_pastell(nx=900, ny=1600, CL=180, rshift=3):
    nz = 3
    mid = nx // 2
    dCL = 50
    #---- start the coloring ----------
    A = np.ones((nx, ny, nz)) * CL  # initialize the image matrix
    #np.random.seed(1234)                  # initialize RNG

    #---- initialize the lower part ----
    ix = slice(0, mid - 1)
    iz = slice(0, nz)  # color the left boundary
    A[ix, 0, iz] = CL + np.cumsum(
        np.random.randint(-rshift, rshift + 1, size=(mid - 1, nz)), axis=0)

    #---- initialize the upper part ----
    ix = slice(mid, nx)
    iz = slice(0, nz)  # color the left boundary
    A[ix, 0, iz] = CL - dCL + np.cumsum(
        np.random.randint(-rshift, rshift + 1, size=(nx - mid, nz)), axis=0)

    #---- march to the right boundary -------------
    ix = slice(1, nx - 1)
    ixm = slice(0, nx - 2)
    ixp = slice(2, nx)
    for jy in range(1, ny):  # smear the color to the right boundary
        A[ix, jy, iz] = 0.3333 * (A[ixm, jy - 1, iz] + A[ix, jy - 1, iz] +
                                  A[ixp, jy - 1, iz]) + np.random.randint(
                                      -rshift, rshift + 1, size=(nx - 2, nz))

    #---- show&save grafics ---------
    im1 = Image.fromarray(A.astype(np.uint8)).convert('RGBA')
    draw1 = ImageDraw.Draw(im1, "RGBA")
    r = random.randint(0, 255)
    g = random.randint(0, 255)
    b = random.randint(0, 255)
    for i in range(randint(0, 10)):
        draw1.rectangle(((randint(0, 6000), randint(0, 6000)),
                         (randint(0, 100), randint(0, 100))),
                        fill=tuple(np.random.randint(256, size=3)) + (60, ))
    im1 = im1.filter(ImageFilter.CONTOUR)
    im1 = im1.filter(ImageFilter.EMBOSS)

    for i in range(randint(0, 500)):
        im1 = im1.filter(ImageFilter.BLUR)
    for i in range(randint(0, 500)):
        im1 = im1.filter(ImageFilter.EDGE_ENHANCE_MORE)
    for i in range(randint(0, 500)):
        im1 = im1.filter(ImageFilter.CONTOUR)
    for i in range(randint(0, 500)):
        im1 = im1.filter(ImageFilter.EDGE_ENHANCE_MORE)

    for i in range(randint(0, 500)):
        im1 = im1.filter(ImageFilter.BLUR)
    for i in range(randint(0, 1000)):
        im1 = im1.filter(ImageFilter.EDGE_ENHANCE_MORE)

    buf = io.BytesIO()
    im1.save(buf, format='PNG')
    thing = buf.getvalue()
    db.drop_all_tables(with_all_data=True)
    db.create_tables()
    with db_session():

        Work(dat=str(base64.b64encode(buf.getvalue()))),

        db.commit()
コード例 #25
0
ファイル: models.py プロジェクト: mwang87/ClassyfireProxy
# models.py
import datetime
from peewee import *
from app import db, retry_db

class ClassyFireEntity(Model):
    inchikey = TextField(unique=True, index=True)
    responsetext = TextField()
    status = TextField()

    class Meta:
        database = db

class FailCaseDB(Model):
    fullstructure = TextField(unique=True,index=True)
    status = TextField()
    
    class Meta:
        database = retry_db

#Creating the Tables
db.create_tables([ClassyFireEntity], safe=True)
retry_db.create_tables([FailCaseDB], safe=True)
コード例 #26
0
ファイル: run.py プロジェクト: tonco/Linker
from app    import app, db
from routes import *
from models import *

if __name__ == '__main__':
    db.create_tables( [ User, Group, Link, UserToGroup ], safe = True )
    app.run()
コード例 #27
0
ファイル: seeds.py プロジェクト: richyarwood/Upcycle-Store
from pony.orm import db_session
from app import db
from models.Category import Category
from models.Listing import Listing
from models.User import User, UserSchema
from models.CartItem import CartItem

db.drop_all_tables(with_all_data=True)
db.create_tables()

with db_session():

    user_schema = UserSchema()

    user1 = User(username='******',
                 email='*****@*****.**',
                 password_hash=user_schema.generate_hash('pass'))

    user2 = User(username='******',
                 email='*****@*****.**',
                 password_hash=user_schema.generate_hash('pass'))

    user3 = User(username='******',
                 email='*****@*****.**',
                 password_hash=user_schema.generate_hash('pass'))

    user4 = User(username='******',
                 email='*****@*****.**',
                 password_hash=user_schema.generate_hash('pass'))

    user5 = User(username='******',
コード例 #28
0
def create_tables():
	with db:
		db.create_tables([Project, PageView, User])
コード例 #29
0
def deploy():
    db.create_tables(app)
    print('deploy success.')
コード例 #30
0
def create_tables():
    db.create_tables([VideoHistory], safe=True)