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

Python ming.create_datastore函数代码示例

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

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



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

示例1: command

 def command(self):
     self._setup_logging()
     self._load_migrations()
     from .runner import run_migration, reset_migration, show_status, set_status
     bind = create_engine(self.options.connection_url)
     if self.options.database is None:
         datastores = [
             create_datastore(db, bind=bind)
             for db in bind.conn.database_names()
             if db not in ('admin', 'local') ]
     else:
         datastores = [ create_datastore(self.options.database, bind=bind) ]
     for ds in datastores:
         self.log.info('Migrate DB: %s', ds.database)
         if self.options.status_only:
             show_status(ds)
         elif self.options.force:
             set_status(ds, self._target_versions())
         elif self.options.reset:
             reset_migration(ds, dry_run=self.options.dry_run)
         else:
             run_migration(ds, self._target_versions(), dry_run=self.options.dry_run)
         try:
             ds.conn.disconnect()
             ds._conn = None
         except: # MIM doesn't do this
             pass
开发者ID:amol-,项目名称:ming-flyway,代码行数:27,代码来源:command.py


示例2: setUp

 def setUp(self):
     self.datastore = create_datastore('mim:///test_db')
     self.session = ODMSession(bind=self.datastore)
     class GrandParent(MappedClass):
         class __mongometa__:
             name='grand_parent'
             session=self.session
         _id = FieldProperty(int)
     class Parent(MappedClass):
         class __mongometa__:
             name='parent'
             session = self.session
         _id = FieldProperty(int)
         grandparent_id = ForeignIdProperty('GrandParent')
         grandparent = RelationProperty('GrandParent')
         children = RelationProperty('Child')
     class Child(MappedClass):
         class __mongometa__:
             name='child'
             session = self.session
         _id = FieldProperty(int)
         parent_id = ForeignIdProperty('Parent', allow_none=True)
         parent = RelationProperty('Parent')
     Mapper.compile_all()
     self.GrandParent = GrandParent
     self.Parent = Parent
     self.Child = Child
开发者ID:vzhz,项目名称:function_generator,代码行数:27,代码来源:test_declarative.py


示例3: includeme

def includeme(config):
    engine = create_datastore(os.getenv(config.registry.settings['mongo_url_env'], 'openrosetta'))
    session.bind = engine
    Mapper.compile_all()

    for mapper in Mapper.all_mappers():
        session.ensure_indexes(mapper.collection)

    config.add_tween('openrosetta.models.ming_autoflush_tween', over=EXCVIEW)
开发者ID:openrosetta,项目名称:openrosetta,代码行数:9,代码来源:__init__.py


示例4: setUp

 def setUp(self):
     self.bind = create_datastore('mim:///testdb')
     self.bind.conn.drop_all()
     self.bind.db.coll.insert(
         {'_id':'foo', 'a':2,
          'b': { 'c': 1, 'd': 2, 'e': [1,2,3],
                 'f': [ { 'g': 1 }, { 'g': 2 } ] },
          'x': {} })
     self.coll = self.bind.db.coll
开发者ID:amol-,项目名称:ming,代码行数:9,代码来源:test_mim.py


示例5: setUp

 def setUp(self):
     self.datastore = create_datastore('mim:///test_db')
     session = Session(bind=self.datastore)
     self.session = ODMSession(session)
     basic = collection('basic', session)
     class Basic(object):
         pass                    
     self.session.mapper(Basic, basic)
     self.basic = basic
     self.Basic = Basic
开发者ID:duilio,项目名称:Ming,代码行数:10,代码来源:test_mapper.py


示例6: create_ming_datastore

 def create_ming_datastore(conf):
     from ming import create_datastore
     url = conf['ming.url']
     database = conf.get('ming.db', '')
     try:
         connection_options = get_partial_dict('ming.connection', conf)
     except AttributeError:
         connection_options = {}
     if database and url[-1] != '/':
         url += '/'
     ming_url = url + database
     return create_datastore(ming_url, **connection_options)
开发者ID:TurboGears,项目名称:tg2,代码行数:12,代码来源:ming.py


示例7: setUp

 def setUp(self):
     self.datastore = create_datastore('mim:///test_db')
     self.session = ThreadLocalODMSession(Session(bind=self.datastore))
     class Parent(MappedClass):
         class __mongometa__:
             name='parent'
             session = self.session
         _id = FieldProperty(S.ObjectId)
     Mapper.compile_all()
     self.Parent = Parent
     self.create_app =  TestApp(MingMiddleware(self._wsgi_create_object))
     self.remove_app =  TestApp(MingMiddleware(self._wsgi_remove_object))
     self.remove_exc =  TestApp(MingMiddleware(self._wsgi_remove_object_exc))
开发者ID:amol-,项目名称:ming,代码行数:13,代码来源:test_middleware.py


示例8: __init__

 def __init__(self, path = None, dbtype = 'auto'):
     """
     path   - Path to store sandbox files.
     dbtype - Type of the dabatabse. [auto|mongo|ming]
     """
     if 'LUNA_TEST_DBTYPE' in os.environ:
         dbtype = os.environ['LUNA_TEST_DBTYPE']
     if not path:
         self.path = tempfile.mkdtemp(prefix='luna')
     else:
         # can cause race condition, but ok
         if not os.path.exists(path):
             os.makedirs(path)
         self.path = path
     self._dbconn = None
     self._mingdatastore = None
     self._mongopath = self.path + "/mongo"
     if not os.path.exists(self._mongopath):
         os.makedirs(self._mongopath)
     self._mongoprocess = None
     if dbtype == 'auto':
         try:
             self._start_mongo()
             self.dbtype = 'mongo'
         except OSError:
             self._mingdatastore = ming.create_datastore('mim:///' + str(uuid.uuid4()))
             self._dbconn = self._mingdatastore.db.luna
             self.dbtype = 'ming'
     elif dbtype == 'mongo':
         self._start_mongo()
         self.dbtype = 'mongo'
     else:
         self._mingdatastore = ming.create_datastore('mim:///' + str(uuid.uuid4()))
         self._dbconn = self._mingdatastore.db.luna
         self.dbtype = 'ming'
     self._create_luna_homedir()
开发者ID:dchirikov,项目名称:luna,代码行数:36,代码来源:helper_utils.py


示例9: setupClass

    def setupClass(cls):
        if ming is None:
            raise SkipTest('Ming not available...')

        cls.basic_session = Session(create_datastore('mim:///'))
        cls.s = ODMSession(cls.basic_session)

        class Author(MappedClass):
            class __mongometa__:
                session = cls.s
                name = 'wiki_author'

            _id = FieldProperty(schema.ObjectId)
            name = FieldProperty(str)
            pages = RelationProperty('WikiPage')

        class WikiPage(MappedClass):
            class __mongometa__:
                session = cls.s
                name = 'wiki_page'

            _id = FieldProperty(schema.ObjectId)
            title = FieldProperty(str)
            text = FieldProperty(str)
            order = FieldProperty(int)
            author_id = ForeignIdProperty(Author)
            author = RelationProperty(Author)

        cls.Author = Author
        cls.WikiPage = WikiPage
        Mapper.compile_all()

        cls.author = Author(name='author1')
        author2 = Author(name='author2')

        WikiPage(title='Hello', text='Text', order=1, author=cls.author)
        WikiPage(title='Another', text='Text', order=2, author=cls.author)
        WikiPage(title='ThirdOne', text='Text', order=3, author=author2)
        cls.s.flush()
        cls.s.clear()
开发者ID:DINKIN,项目名称:tg2,代码行数:40,代码来源:test_pagination.py


示例10: dict

from ming import create_datastore
from ming.odm import ThreadLocalODMSession
from litminer import config

auth = dict(config["mongodb"])
uri = auth.pop("uri",None)

session = ThreadLocalODMSession(
    bind=create_datastore(uri=uri,authenticate=auth)
)
开发者ID:swatford,项目名称:litminer,代码行数:10,代码来源:__init__.py


示例11: __init__

    def __init__(self, mongo_uri):

        if mongo_uri[0]=='$':
            mongo_uri = os.getenv(mongo_uri[1:])
        self.mongo_engine = create_datastore(mongo_uri)
开发者ID:simock85,项目名称:spynach_ming,代码行数:5,代码来源:__init__.py


示例12: setUp

 def setUp(self):
   self.mg = ming.create_datastore('mim://', db='nba', **kwargs)
   self.nbam = NBAMongo(self.mg.db)
   self.games = []
   self.standings = []
   self._get_scoreboard()
开发者ID:Sandy4321,项目名称:nbacom-python,代码行数:6,代码来源:NBAMongo_test.py


示例13: setUp

 def setUp(self):
     self.bind = create_datastore('mim:///testdb')
     self.bind.conn.drop_all()
开发者ID:duilio,项目名称:Ming,代码行数:3,代码来源:test_mim.py


示例14: setUp

 def setUp(self):
     self.ds = create_datastore("mim:///test")
     self.Session = Session(bind=self.ds)
     self.TestFS = fs.filesystem("test_fs", self.Session)
开发者ID:vzhz,项目名称:function_generator,代码行数:4,代码来源:test_gridfs.py


示例15: create_datastore

from ming import Session, create_datastore
from ming import Document, Field, schema
import json
import urllib2

bind = create_datastore('mongodb://localhost/paperMiningTest')
session = Session(bind)

class Paper(Document):

    class __mongometa__:
        session = session
        name = 'paperCoCitation'

    id = Field(str) 
    cocitation = Field([]) #put cite paper id

if __name__ == '__main__':
    baseUrl = "http://140.118.175.209/paper/cocitation.php?ids="
    with open('paperId.json') as data_file:
        data = json.load(data_file)
    for paperId in data["CitationId"]:
        url = baseUrl + str(paperId)
        arr = = json.load(urllib2.urlopen(url))
        if len(arr) is not 0:
            cocitationRelationDic = arr[0]
            paperRel = Paper(dict(id = cocitationRelationDic["id"],cocitation = cocitationRelationDic["co_citation"]))
            paperRel.m.save()
            print paperRel
        else:
            print "No cocitation"
开发者ID:man27382210,项目名称:python_test,代码行数:31,代码来源:co_citation_parse.py


示例16: Copyright

#  Copyright      : Copyright (c) 2012-2015 David Fischer. All rights reserved.
#
#**********************************************************************************************************************#
#
# This file is part of David Fischer's pytoolbox Project.
#
# This project is free software: you can redistribute it and/or modify it under the terms of the EUPL v. 1.1 as provided
# by the European Commission. This project is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See the European Union Public License for more details.
#
# You should have received a copy of the EUPL General Public License along with this project.
# If not, see he EUPL licence v1.1 is available in 22 languages:
#     22-07-2013, <https://joinup.ec.europa.eu/software/page/eupl/licence-eupl>
#
# Retrieved from https://github.com/davidfischer-ch/pytoolbox.git

from __future__ import absolute_import, division, print_function, unicode_literals

from ming import create_datastore, Session
from ming.odm import ThreadLocalODMSession

from .. import module

_all = module.All(globals())

bind = create_datastore('mim://')
doc_session = Session(bind)
odm_session = ThreadLocalODMSession(doc_session=doc_session)
开发者ID:tonysepia,项目名称:pytoolbox,代码行数:30,代码来源:session.py


示例17: incr

        import json
        self.set_raw(name, key, json.dumps(value)) 
        
    def incr(self, name, key, amount=1):
        val = self.get(name, key)
        if val:
            val += amount
        else:
            val = amount
        self.set(name, key, val)
        return val  
    
from stubo.cache import Cache
from stubo.model.db import Scenario
import ming
mg = ming.create_datastore('mim://')

class DummyScenario(Scenario):
    
    def __init__(self):
        dbname = testdb_name()
        client = getattr(mg.conn, dbname)
        Scenario.__init__(self, db=client)
        
    def __call__(self, **kwargs):
        return self  
    
    # derive these methods as ming hasn't implemented '$regex' matching
    
    def get_all(self, name=None):
        if name and isinstance(name, dict) and '$regex' in name:
开发者ID:JohnFDavenport,项目名称:stubo-app,代码行数:31,代码来源:testing.py


示例18: create_ming_datastore

 def create_ming_datastore():
     return create_datastore(os.environ.get('MONGOURL', 'mongodb://127.0.0.1:27017/test_db'))
开发者ID:TurboGears,项目名称:sprox,代码行数:2,代码来源:base.py


示例19: initialize_collection

 def initialize_collection(self):
     client = ming.create_datastore(self.get_property('url')).conn
     return client[self.get_property('database')][self.get_property(
         'collection')]
开发者ID:httpPrincess,项目名称:metahosting,代码行数:4,代码来源:ming_store.py


示例20: Session

# coding=utf-8

from ming import create_datastore, Session
from ming.odm import ODMSession
import os


session = Session()
session.bind = create_datastore(os.environ.get('MONGO_URL'))
odm_session = ODMSession(session)
开发者ID:andrR89,项目名称:lol_tcc_api,代码行数:10,代码来源:__init__.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python base.Object类代码示例发布时间:2022-05-27
下一篇:
Python ming.configure函数代码示例发布时间: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