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


Python DBSession.execute方法代码示例

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


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

示例1: tearDown

# 需要导入模块: from bookie.models import DBSession [as 别名]
# 或者: from bookie.models.DBSession import execute [as 别名]
 def tearDown(self):
     """Regular tear down method"""
     session = DBSession()
     Bmark.query.delete()
     Tag.query.delete()
     session.execute(bmarks_tags.delete())
     session.flush()
     transaction.commit()
开发者ID:aldeka,项目名称:Bookie,代码行数:10,代码来源:test_imports.py

示例2: tearDown

# 需要导入模块: from bookie.models import DBSession [as 别名]
# 或者: from bookie.models.DBSession import execute [as 别名]
 def tearDown(self):
     """Tear down each test"""
     testing.tearDown()
     session = DBSession()
     Bmark.query.delete()
     Tag.query.delete()
     session.execute(bmarks_tags.delete())
     session.flush()
     transaction.commit()
开发者ID:briangershon,项目名称:Bookie,代码行数:11,代码来源:test_fulltext.py

示例3: empty_db

# 需要导入模块: from bookie.models import DBSession [as 别名]
# 或者: from bookie.models.DBSession import execute [as 别名]
def empty_db():
    """On teardown, remove all the db stuff"""

    Bmark.query.delete()
    Readable.query.delete()
    # we can't remove the toread tag we have from our commands
    Tag.query.filter(Tag.name != 'toread').delete()
    Hashed.query.delete()

    DBSession.execute(bmarks_tags.delete())
    DBSession.flush()
    transaction.commit()
开发者ID:aldeka,项目名称:Bookie,代码行数:14,代码来源:__init__.py

示例4: tearDown

# 需要导入模块: from bookie.models import DBSession [as 别名]
# 或者: from bookie.models.DBSession import execute [as 别名]
    def tearDown(self):
        """We need to empty the bmarks table on each run"""
        testing.tearDown()

        if BOOKIE_TEST_INI == 'test.ini':
            SqliteBmarkFT.query.delete()
        Bmark.query.delete()
        Tag.query.delete()
        Hashed.query.delete()

        DBSession.execute(bmarks_tags.delete())
        DBSession.flush()
        transaction.commit()
开发者ID:lmorchard,项目名称:Bookie,代码行数:15,代码来源:__init__.py

示例5: empty_db

# 需要导入模块: from bookie.models import DBSession [as 别名]
# 或者: from bookie.models.DBSession import execute [as 别名]
def empty_db():
    """On teardown, remove all the db stuff"""

    if BOOKIE_TEST_INI == 'test.ini':
        SqliteBmarkFT.query.delete()
    Bmark.query.delete()
    # we can't remove the toread tag we have from our commands
    Tag.query.filter(Tag.name != 'toread').delete()
    Hashed.query.delete()

    DBSession.execute(bmarks_tags.delete())
    DBSession.flush()
    transaction.commit()
开发者ID:lmorchard,项目名称:Bookie,代码行数:15,代码来源:__init__.py

示例6: tearDown

# 需要导入模块: from bookie.models import DBSession [as 别名]
# 或者: from bookie.models.DBSession import execute [as 别名]
    def tearDown(self):
        """We need to empty the bmarks table on each run"""
        testing.tearDown()

        # DBSession.execute("TRUNCATE bmarks;")
        # DBSession.execute("TRUNCATE fulltext;")
        # DBSession.execute("TRUNCATE tags;")
        # DBSession.execute("TRUNCATE bmarks_tags;")
        SqliteModel.query.delete()
        Bmark.query.delete()
        Tag.query.delete()
        DBSession.execute(bmarks_tags.delete())
        DBSession.flush()
        transaction.commit()
开发者ID:briangershon,项目名称:Bookie,代码行数:16,代码来源:__init__.py

示例7: empty_db

# 需要导入模块: from bookie.models import DBSession [as 别名]
# 或者: from bookie.models.DBSession import execute [as 别名]
def empty_db():
    """On teardown, remove all the db stuff"""
    DBSession.execute(bmarks_tags.delete())
    Readable.query.delete()
    Bmark.query.delete()
    Tag.query.delete()
    # we can't remove the toread tag we have from our commands
    Hashed.query.delete()
    ImportQueue.query.delete()

    DBSession.flush()
    transaction.commit()

    # Clear the fulltext index as well.
    _reset_index()
开发者ID:cambot,项目名称:Bookie,代码行数:17,代码来源:__init__.py

示例8: api_key

# 需要导入模块: from bookie.models import DBSession [as 别名]
# 或者: from bookie.models.DBSession import execute [as 别名]
 def api_key(self):
     """Cache the api key for all calls."""
     if not self._api_key:
         res = DBSession.execute(
             "SELECT api_key FROM users WHERE username='admin'").fetchone()
         self._api_key = res['api_key']
     return self._api_key
开发者ID:BraindeadCrew,项目名称:Bookie,代码行数:9,代码来源:test_admin.py

示例9: test_google_import

# 需要导入模块: from bookie.models import DBSession [as 别名]
# 或者: from bookie.models.DBSession import execute [as 别名]
    def test_google_import(self):
        """Test that we can upload our google file"""
        self.testapp.post('/login',
                            params={
                                "login": "admin",
                                "password": "admin",
                                "form.submitted": "Log In",
                            },
                            status=302)

        session = DBSession()
        loc = os.path.dirname(__file__)
        del_file = open(os.path.join(loc, 'googlebookmarks.html'))
        res = DBSession.execute("SELECT api_key FROM users WHERE username = 'admin'").fetchone()
        API_KEY = res['api_key']

        post = {
            'api_key': API_KEY,
        }


        res = self.testapp.post('/admin/import',
                                params=post,
                                upload_files=[('import_file',
                                               'googlebookmarks.html',
                                               del_file.read())],
        )

        eq_(res.status, "302 Found",
            msg='Import status is 302 redirect by home, ' + res.status)

        session.flush()

        # test all the data we want to test after the import
        _google_data_test()
开发者ID:aldeka,项目名称:Bookie,代码行数:37,代码来源:test_imports.py

示例10: test_add_bookmark

# 需要导入模块: from bookie.models import DBSession [as 别名]
# 或者: from bookie.models.DBSession import execute [as 别名]
    def test_add_bookmark(self):
        """We should be able to add a new bookmark to the system"""
        # we need to know what the current admin's api key is so we can try to
        # add
        res = DBSession.execute(
            "SELECT api_key FROM users WHERE username = 'admin'").fetchone()
        key = res['api_key']

        test_bmark = {
            'url': u'http://bmark.us',
            'description': u'Bookie',
            'extended': u'Extended notes',
            'tags': u'bookmarks',
            'api_key': key,
        }

        res = self.testapp.post('/api/v1/admin/bmark',
                                params=test_bmark,
                                status=200)

        self.assertTrue(
            '"location":' in res.body,
            "Should have a location result: " + res.body)
        self.assertTrue(
            'description": "Bookie"' in res.body,
            "Should have Bookie in description: " + res.body)
        self._check_cors_headers(res)
开发者ID:BraindeadCrew,项目名称:Bookie,代码行数:29,代码来源:test_base_api.py

示例11: setUp

# 需要导入模块: from bookie.models import DBSession [as 别名]
# 或者: from bookie.models.DBSession import execute [as 别名]
    def setUp(self):
        from pyramid.paster import get_app
        app = get_app(BOOKIE_TEST_INI, 'main')
        from webtest import TestApp
        self.testapp = TestApp(app)
        testing.setUp()

        global API_KEY
        res = DBSession.execute("SELECT api_key FROM users WHERE username = 'admin'").fetchone()
        API_KEY = res['api_key']
开发者ID:lmorchard,项目名称:Bookie,代码行数:12,代码来源:__init__.py

示例12: empty_db

# 需要导入模块: from bookie.models import DBSession [as 别名]
# 或者: from bookie.models.DBSession import execute [as 别名]
def empty_db():
    """On teardown, remove all the db stuff"""
    DBSession.execute(bmarks_tags.delete())
    Readable.query.delete()
    Bmark.query.delete()
    StatBookmark.query.delete()
    Tag.query.delete()
    # we can't remove the toread tag we have from our commands
    Hashed.query.delete()
    ImportQueue.query.delete()
    # Delete the users not admin in the system.
    Activation.query.delete()
    User.query.filter(User.username != u'admin').delete()

    AppLog.query.delete()
    DBSession.flush()
    transaction.commit()

    # Clear the fulltext index as well.
    _reset_index()
开发者ID:BraindeadCrew,项目名称:Bookie,代码行数:22,代码来源:__init__.py

示例13: setUp

# 需要导入模块: from bookie.models import DBSession [as 别名]
# 或者: from bookie.models.DBSession import execute [as 别名]
 def setUp(self):
     """Setup Tests"""
     from pyramid.paster import get_app
     from bookie.tests import BOOKIE_TEST_INI
     app = get_app(BOOKIE_TEST_INI, 'bookie')
     from webtest import TestApp
     self.app = TestApp(app)
     testing.setUp()
     res = DBSession.execute(
         "SELECT api_key FROM users WHERE username = 'admin'").\
         fetchone()
     self.api_key = res['api_key']
开发者ID:BraindeadCrew,项目名称:Bookie,代码行数:14,代码来源:__init__.py

示例14: test_add_bookmark_empty_body

# 需要导入模块: from bookie.models import DBSession [as 别名]
# 或者: from bookie.models.DBSession import execute [as 别名]
    def test_add_bookmark_empty_body(self):
        """When missing a POST body we get an error response."""
        res = DBSession.execute(
            "SELECT api_key FROM users WHERE username = 'admin'").fetchone()
        key = res['api_key']

        res = self.testapp.post(
            str('/api/v1/admin/bmark?api_key={0}'.format(key)),
            params={},
            status=400)

        data = json.loads(res.body)
        self.assertTrue('error' in data)
        self.assertEqual(data['error'], 'Bad Request: No url provided')
开发者ID:BraindeadCrew,项目名称:Bookie,代码行数:16,代码来源:test_base_api.py

示例15: setUp

# 需要导入模块: from bookie.models import DBSession [as 别名]
# 或者: from bookie.models.DBSession import execute [as 别名]
    def setUp(self):
        """Setup Tests"""
        from pyramid.paster import get_app
        from bookie.tests import BOOKIE_TEST_INI

        app = get_app(BOOKIE_TEST_INI, "bookie")
        from webtest import TestApp

        self.testapp = TestApp(app)
        testing.setUp()
        global API_KEY
        if API_KEY is None:
            res = DBSession.execute("SELECT api_key FROM users WHERE username = 'admin'").fetchone()
            API_KEY = res["api_key"]
开发者ID:EdwardNavarro,项目名称:Bookie,代码行数:16,代码来源:test_fulltext.py


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