• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.initialize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.initialize函数的典型用法代码示例。如果您正苦于以下问题:Python initialize函数的具体用法?Python initialize怎么用?Python initialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了initialize函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: setup_database

def setup_database():
    """ Initialize the database file, maybe drop all tables. """

    # -------------------------------------------------------------------------
    #   Set up the database.
    # -------------------------------------------------------------------------
    # !!AI uncomment me when needed.
    #models.drop_all()
    models.initialize()
开发者ID:asimihsan,项目名称:fakestartupguru,代码行数:9,代码来源:gather.py


示例2: setUp

 def setUp(self):
     """Runs before every test, creating the User table and
        one entry if either are not present"""
     # Opens connection, creates table, and closes connection
     models.initialize()
     # Creates one mock entry in the database
     models.User.create_user(username='testUsername',
                             email='[email protected]',
                             password='testPassword')
     # Retrieves mock entry from database and stores it locally
     self.user = models.User.get(email='[email protected]')
开发者ID:nicolasjhampton,项目名称:python_tutorial_game_project,代码行数:11,代码来源:_model_tests.py


示例3: init

def init():
    db_session = DBSession()
    system_version = SystemVersion.get(db_session)

    # Handles database schema migration
    for version in range(system_version.schema_version, CURRENT_SCHEMA_VERSION+1):    
        handler_class = get_schema_migrate_class(version)
        if handler_class is not None:
            try:
                handler_class(version).execute()
            except:
                print(traceback.format_exc())

    # Initialize certain tables 
    initialize()
开发者ID:ponnadarahul,项目名称:csm,代码行数:15,代码来源:initialize.py


示例4: __init__

    def __init__(self, db_name, encrypter=None, store_text=True):
        self.session_maker = models.initialize(db_name)
        self.session = None

        models.ENCRYPTER = encrypter

        self.store_text = store_text

        self.nrmoves = 0
        self.latestx = 0
        self.latesty = 0
        self.lastspecial = None
        self.specials_in_row = 0

        self.curtext = u""
        self.key_presses = []
        self.last_key_time = time.time()
        
        self.started = NOW()
        self.cur_class = None
        self.cur_window = None
        self.cur_name = None
        self.cur_process_id = None
        self.cur_win_id = None
        self.cur_win_proc = None
开发者ID:thenoviceoof,项目名称:selfspy,代码行数:25,代码来源:activity_store.py


示例5: index

def index():
  return 'Hey'
  
  
  
  if __name__ == '__main__':
    models.initialize()
    try:
       models.User.create_user(
            username='juliancruz',
            email='[email protected]',
            password='password',
            admin=True
    )
    except ValueError:
      pass
    app.run(debug=DEBUG, host=HOST, port=PORT)
开发者ID:juliancrosss,项目名称:socialpy,代码行数:17,代码来源:app.py


示例6: init

def init():
    db_session = DBSession()
    system_version = SystemVersion.get(db_session)

    # Handles database schema migration starting from the next schema version
    for version in range(system_version.schema_version + 1, CURRENT_SCHEMA_VERSION + 1):
        handler_class = get_schema_migrate_class(version)
        if handler_class is not None:
            try:
                handler_class(version).execute()
            except:
                print(traceback.format_exc())

    apply_dialect_specific_codes()

    # Initialize certain tables 
    initialize()
开发者ID:smjurcak,项目名称:csm,代码行数:17,代码来源:initialize.py


示例7: init

def init():
    if not is_ldap_supported():
        print('LDAP authentication is not supported because it has not been installed.')

    db_session = DBSession()
    system_version = SystemVersion.get(db_session)

    # Handles database schema migration starting from the next schema version
    for version in range(system_version.schema_version + 1, CURRENT_SCHEMA_VERSION + 1):
        handler_class = get_schema_migrate_class(version)
        if handler_class is not None:
            try:
                handler_class(version).execute()
            except:
                print(traceback.format_exc())

    # Initialize certain tables 
    initialize()
开发者ID:anushreejangid,项目名称:csm,代码行数:18,代码来源:initialize.py


示例8: __init__

    def __init__(self, db_name, encrypter=None, store_text=True):
        self.session_maker = models.initialize(db_name)

        models.ENCRYPTER = encrypter

        self.store_text = store_text
        self.curtext = u""

        self.key_presses = []
        self.mouse_path = []

        self.current_window = Display()

        self.last_key_time = time.time()
        self.started = NOW()
开发者ID:arttaylor,项目名称:selfspy,代码行数:15,代码来源:activity_store.py


示例9: flash

		try:
			user = models.User.get(models.User.email == form.email.data)
		except models.DoesNotExist:
			flash("Your email or password doesn't match.", "error")
		else:
			if check_password_hash(user.password, form.password.data):
				login_user(user)
				flash("You've been logged in!", "success")
				return redirect(url_for('index'))
			else:
				flash("Your email or password doesn't match.", "error")
	return render_template('login.html', form = form)
	
@app.route('/')
def index():
	return 'Hey'	
	
if __name__ == '__main__':
	models.initialize()
	try:
		models.User.create_user(
			username = 'fionarowan',
			email = '[email protected]',
			password = 'password',
			admin=True
		)
	except ValueError:
		pass
	app.run(debug=DEBUG, host = HOST, port = PORT)
		
开发者ID:juliarg,项目名称:aerodactyl,代码行数:29,代码来源:fApp.py


示例10: Database

#!/usr/bin/env python

from database import MDB as Database

from config import dbconf, bsconf
from models import *

import models

if __name__ == "__main__":
    database = Database(**dbconf)
    blobstore = None # Blobstore(bsconf.nodes, **bsconf.opts)
    models.initialize(database, blobstore)
    database.create_tables([
        User,
        Token,
        Repo,
        HMap,
        CSet,
        Blob,
        CommitMessage
    ], safe=True)
开发者ID:SemanticMultimedia,项目名称:tlr,代码行数:22,代码来源:prepare.py


示例11: __init__

    def __init__(self, db_name, args):
        self.args = args
        self.session_maker = models.initialize(db_name)
        self.inmouse = False

        self.check_needs()
开发者ID:thenoviceoof,项目名称:selfspy,代码行数:6,代码来源:selfstats.py


示例12: logout

@login_required
def logout():
    logout_user()
    return redirect(url_for("index"))


@app.route("/taco", methods=('GET', 'POST'))
@login_required
def taco():
    form = TacoForm()
    if form.validate_on_submit():
        Taco.create(
            protein=form.protein.data,
            shell=form.shell.data,
            cheese=form.cheese.data,
            extras=form.extras.data,
            user=current_user._get_current_object()
        )
        return redirect(url_for("index"))

    return render_template("taco.html", form=form)


@app.route("/")
def index():
    return render_template("index.html", tacos=Taco.select())


if __name__ == "__main__":
    initialize()
    app.run(port=8000,debug=True, host="localhost")
开发者ID:guillaumemaka,项目名称:tacocat_treehouse_challenge,代码行数:31,代码来源:tacocat.py


示例13: define

from database import PooledMDB as Database

import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web

from tornado.options import define, options

define("port", default=5000, help="port to bind to", type=int)

from config import settings, dbconf, bsconf
from routes import routes

import models

class Application(tornado.web.Application):
    def __init__(self, dbconf, bsconf, handlers=None, **settings):
        super(Application, self).__init__(handlers, **settings)
        self.blobstore = None # Blobstore(bsconf.nodes, **bsconf.opts)
        self.database = Database(stale_timeout=599, **dbconf)

if __name__ == "__main__":
    tornado.options.parse_command_line()
    app = Application(dbconf, bsconf, routes, **settings)
    models.initialize(app.database, app.blobstore)
    server = tornado.httpserver.HTTPServer(app)
    server.listen(tornado.options.options.port)
    tornado.ioloop.IOLoop.instance().start()
开发者ID:olegsfinest,项目名称:tlr,代码行数:29,代码来源:app.py


示例14: flash

		else:
			flash('You have unfollowing {}!'.format(to_user.username), 'alert-success')

	return redirect(url_for('stream', username=to_user.username))




@app.errorhandler(404) # error handeling view function
def not_found(error):
	return render_template('404.html'), 404



if __name__ == '__main__': # launching our falsk application
	
	models.initialize() # initializing our models in the database 

	try:
		models.User.create_user(username='athoug', email='[email protected]', password='password', name='Athoug Alsoughayer', department='CS') # for testing purposes 
	
	except ValueError:
		pass	

	app.run(debug=DEBUG)





开发者ID:geekyjulie,项目名称:Open-GW,代码行数:25,代码来源:app.py



注:本文中的models.initialize函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.next_id函数代码示例发布时间:2022-05-27
下一篇:
Python models.get_sorted_profiles函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap