当前位置: 首页>>代码示例>>Python>>正文


Python MongoEngine.connect方法代码示例

本文整理汇总了Python中flask.ext.mongoengine.MongoEngine.connect方法的典型用法代码示例。如果您正苦于以下问题:Python MongoEngine.connect方法的具体用法?Python MongoEngine.connect怎么用?Python MongoEngine.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask.ext.mongoengine.MongoEngine的用法示例。


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

示例1: get_db

# 需要导入模块: from flask.ext.mongoengine import MongoEngine [as 别名]
# 或者: from flask.ext.mongoengine.MongoEngine import connect [as 别名]
def get_db(database=None):
    if not database:
        database = conf.MONGODB_DB
    if os.environ.get("UNITTEST_MODE"):
        database = conf.MONGODB_DB_UNITTEST
    mongo = MongoEngine()
    mongo.connect(
        database,
        host=conf.MONGODB_HOST,
        port=conf.MONGODB_PORT,
        username=conf.MONGODB_USER,
        password=conf.MONGODB_PASSWD
    )
    return mongo
开发者ID:zhy0216-collection,项目名称:ezlog2,代码行数:16,代码来源:db.py

示例2: Flask

# 需要导入模块: from flask.ext.mongoengine import MongoEngine [as 别名]
# 或者: from flask.ext.mongoengine.MongoEngine import connect [as 别名]
import os
from flask import Flask,request
from flask import Flask,render_template
import requests
import json
import datetime
import collections
from flask import jsonify
from models.models import *
from flask.ext.mongoengine import MongoEngine
from flask.ext.mongoengine.wtf import model_form

app = Flask(__name__)
app.config.from_object('config')
mongoDb = MongoEngine(app)
mongoDb.connect()


def convert(data):
    if isinstance(data, basestring):
        return str(data)
    elif isinstance(data, collections.Mapping):
        return dict(map(convert, data.iteritems()))
    elif isinstance(data, collections.Iterable):
        return type(data)(map(convert, data))
    else:
        return data

@app.route('/')
@app.route('/index')
def index():
开发者ID:sharadvishe,项目名称:Statistic-Logger,代码行数:33,代码来源:app.py

示例3: import

# 需要导入模块: from flask.ext.mongoengine import MongoEngine [as 别名]
# 或者: from flask.ext.mongoengine.MongoEngine import connect [as 别名]
from flask.ext.mongoengine.wtf import model_form
from flask.ext.cors import CORS
from flask import  Flask, abort, request, jsonify, g, url_for,render_template
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.httpauth import HTTPBasicAuth

from passlib.apps import custom_app_context as pwd_context
from itsdangerous import (TimedJSONWebSignatureSerializer
                          as Serializer, BadSignature, SignatureExpired)

# initialization
app = Flask(__name__)
CORS(app)
app.config.from_object('config')
mongo_db = MongoEngine(app)
mongo_db.connect()


app.config['SECRET_KEY'] = 'the quick brown fox jumps over the lazy dog'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True

# extensions
db = SQLAlchemy(app)
auth = HTTPBasicAuth()


class User(db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(32), index=True)
开发者ID:sharadvishe,项目名称:lrsapis,代码行数:33,代码来源:app.py

示例4: Flask

# 需要导入模块: from flask.ext.mongoengine import MongoEngine [as 别名]
# 或者: from flask.ext.mongoengine.MongoEngine import connect [as 别名]
from flask.ext.mongoengine import MongoEngine
from flask.views import MethodView
from mongoengine.queryset import Q


app = Flask(__name__)
#initialise DB
db = MongoEngine(app)

#configure DB
app.config['MONGODB_SETTINGS'] = {
    'db': 'test',
}

#connect to DB
db.connect('test')

#route with get request
@app.route('/')
def index():
        return render_template('map.html')

class taxis(db.Document):
	taxi_id = db.IntField()
	lng = db.FloatField()
	lat = db.FloatField()
	vel = db.FloatField()
	drt = db.FloatField()
	carry = db.IntField()
	time = db.IntField()
开发者ID:zaleCao,项目名称:hztaxi,代码行数:32,代码来源:hztaxi.py


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