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

Python serializer.loads函数代码示例

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

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



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

示例1: stoccaggio_table

def stoccaggio_table(soup=None, op=None,dao=None, row=None, all=False):
    d = None
    if soup and not all:
        record = soup.stoccaggio.get(loads(row.object))
    else:
        record = row
    if op =="DELETE":
        if all:
            d = Stoccaggio().getRecord(id=row.id)
        else:
            d = Stoccaggio().getRecord(id=loads(row.object))
        if d:
            d.delete()
        return True
    elif op == "INSERT":
        if all:
            d = Stoccaggio()
            d.id = record.id
        else:
            d = Stoccaggio().getRecord(id=loads(row.object))
    elif op == "UPDATE":
        if all:
            d = Stoccaggio().getRecord(id=row.id)
        else:
            d = Stoccaggio().getRecord(id=loads(row.object))
    d.scorta_minima= record.scorta_minima
    d.livello_riordino = record.livello_riordino
    d.data_fine_scorte =record.data_fine_scorte
    d.data_prossimo_ordine = record.data_prossimo_ordine
    d.id_articolo = record.id_articolo
    d.id_magazzino = record.id_magazzino


    d.persist()
    return True
开发者ID:Alwnikrotikz,项目名称:promogest,代码行数:35,代码来源:stoccaggio_table.py


示例2: listino_magazzino_table

def listino_magazzino_table(soup=None, op=None, dao=None, row=None,all=False):
    d = None
    if soup and not all:
        record = soup.listino_magazzino.get(loads(row.object))
    else:
        record = row
    if op =="DELETE":
        if all:
            d = ListinoMagazzino().getRecord(id=[row.id_listino,row.id_magazzino])
        else:
            d = ListinoMagazzino().getRecord(id=loads(row.object))
        if d:
            d.delete()
        return True
    elif op == "INSERT":
        if all:
            d = ListinoMagazzino()
            d.id_listino = record.id_listino
            d.id_magazzino = record.id_magazzino
        else:
            d = ListinoArticolo().getRecord(id=loads(row.object))
    elif op == "UPDATE":
        if all:
            d = ListinoArticolo().getRecord(id=[row.id_listino,row.id_magazzino])
            #if d:
                #d = d[0]
        else:
            d = ListinoArticolo().getRecord(id=loads(row.object))
    d.persist()
    return True
开发者ID:Alwnikrotikz,项目名称:promogest,代码行数:30,代码来源:listino_magazzino_table.py


示例3: sconto_table

def sconto_table(soup=None, op=None, dao=None,rowLocale=None, row=None, all=False):
    d = None
    if soup and not all:
        record = soup.sconto.get(loads(row.object))
    else:
        record = row
    if op =="DELETE":
        if all:
            d = Sconto().getRecord(id=row.id)
        else:
            d = Sconto().getRecord(id=loads(row.object))
        if d:
            d.delete()
        return True
    elif op == "INSERT":
        if all:
            d = Sconto()
            d.id = record.id
        else:
            d = Sconto().getRecord(id=loads(row.object))
    elif op == "UPDATE":
        if all:
            d = Sconto().getRecord(id=row.id)
        else:
            d = Sconto().getRecord(id=loads(row.object))
        if not d:
            d = Sconto()
            d.id = record.id
    d.valore = record.valore
    d.tipo_sconto= record.tipo_sconto
    d.persist()
    return True
开发者ID:fmarella,项目名称:pg3,代码行数:32,代码来源:sconto_table.py


示例4: main

def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    settings = get_appsettings(config_uri)
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.drop_all(engine)
    Base.metadata.create_all(engine)
#    delete_all()
    with transaction.manager:
        f = open("./db_backup.txt", 'r');
        serialized_data = pickle.load(f)
        serialized_menu_items = serialized_data["menu_items"]
        menu_items = loads(serialized_menu_items, Base.metadata, DBSession)
        print menu_items
        print "hello"
        for menu_item in menu_items:
            DBSession.merge(menu_item)
            print 'menu_item is %r'%menu_item
        print "hello done"
        serialized_allergens = serialized_data["allergens"]
        allergens = loads(serialized_allergens, Base.metadata, DBSession)
        for allergen in allergens:
            DBSession.merge(allergen)
        serialized_menus = serialized_data["menus"]
        menus = loads(serialized_menus, Base.metadata, DBSession)
        for menu in menus:
            DBSession.merge(menu)
开发者ID:tinawen,项目名称:menu,代码行数:30,代码来源:loaddb.py


示例5: test_query_one

    def test_query_one(self):
        q = Session.query(User).\
                filter(User.name == 'ed').\
                    options(joinedload(User.addresses))

        q2 = serializer.loads(
                    serializer.dumps(q, -1),
                            users.metadata, Session)
        def go():
            eq_(q2.all(), [
                    User(name='ed', addresses=[Address(id=2),
                    Address(id=3), Address(id=4)])])

        self.assert_sql_count(testing.db, go, 1)

        eq_(q2.join(User.addresses).filter(Address.email
            == '[email protected]').value(func.count('*')), 1)
        u1 = Session.query(User).get(8)
        q = Session.query(Address).filter(Address.user
                == u1).order_by(desc(Address.email))
        q2 = serializer.loads(serializer.dumps(q, -1), users.metadata,
                              Session)
        eq_(q2.all(), [Address(email='[email protected]'),
            Address(email='[email protected]'),
            Address(email='[email protected]')])
开发者ID:idella,项目名称:sqlalchemy,代码行数:25,代码来源:test_serializer.py


示例6: categoria_cliente_table

def categoria_cliente_table(soup=None, op=None, dao=None, row=None, all=False):
    d = None
    if soup and not all:
        record = soup.categoria_cliente.get(loads(row.object))
    else:
        record = row
    if op =="DELETE":
        if all:
            d = CategoriaCliente().getRecord(id=row.id)
        else:
            d = CategoriaCliente().getRecord(id=loads(row.object))
        if d:
            d.delete()
        return True
    elif op == "INSERT":
        if all:
            d = CategoriaCliente()
            d.id = record.id
        else:
            d = CategoriaCliente().getRecord(id=loads(row.object))
    elif op == "UPDATE":
        if all:
            d = CategoriaCliente().getRecord(id=row.id)
        else:
            d = CategoriaCliente().getRecord(id=loads(row.object))
    d.descrizione = record.descrizione
    d.denominazione= record.denominazione
    d.active= record.active
    d.persist()
    return True
开发者ID:Alwnikrotikz,项目名称:promogest,代码行数:30,代码来源:categoria_cliente_table.py


示例7: test_query

    def test_query(self):
        q = Session.query(User).filter(User.name == "ed").options(eagerload(User.addresses))
        eq_(q.all(), [User(name="ed", addresses=[Address(id=2), Address(id=3), Address(id=4)])])

        q2 = serializer.loads(serializer.dumps(q, -1), users.metadata, Session)

        def go():
            eq_(q2.all(), [User(name="ed", addresses=[Address(id=2), Address(id=3), Address(id=4)])])

        self.assert_sql_count(testing.db, go, 1)

        eq_(q2.join(User.addresses).filter(Address.email == "[email protected]").value(func.count("*")), 1)

        u1 = Session.query(User).get(8)

        q = Session.query(Address).filter(Address.user == u1).order_by(desc(Address.email))
        q2 = serializer.loads(serializer.dumps(q, -1), users.metadata, Session)

        eq_(q2.all(), [Address(email="[email protected]"), Address(email="[email protected]"), Address(email="[email protected]")])

        q = Session.query(User).join(User.addresses).filter(Address.email.like("%fred%"))
        q2 = serializer.loads(serializer.dumps(q, -1), users.metadata, Session)
        eq_(q2.all(), [User(name="fred")])

        eq_(list(q2.values(User.id, User.name)), [(9, u"fred")])
开发者ID:obeattie,项目名称:sqlalchemy,代码行数:25,代码来源:test_serializer.py


示例8: sconti_vendita_dettaglio_table

def sconti_vendita_dettaglio_table(soup=None, op=None, dao=None,rowLocale=None, row=None, all=False):
    d = None
    if soup and not all:
        record = soup.sconti_vendita_dettaglio.get(loads(row.object))
    else:
        record = row
    if op =="DELETE":
        if all:
            d = ScontoVenditaDettaglio().getRecord(id=row.id)
        else:
            d = ScontoVenditaDettaglio().getRecord(id=loads(row.object))
        if d:
            d.delete()
        return True
    elif op == "INSERT":
        if all:
            d = ScontoVenditaDettaglio()
            d.id = record.id
        else:
            d = ScontoVenditaDettaglio().getRecord(id=loads(row.object))
    elif op == "UPDATE":
        if all:
            d = ScontoVenditaDettaglio().getRecord(id=row.id)
        else:
            d = ScontoVenditaDettaglio().getRecord(id=loads(row.object))
        if not d:
            d = ScontoVenditaDettaglio()
            d.id = record.id
    d.id_listino = record.id_listino
    d.id_articolo = record.id_articolo
    d.data_listino_articolo = record.data_listino_articolo

    d.persist()
    return True
开发者ID:Alwnikrotikz,项目名称:promogest,代码行数:34,代码来源:sconti_vendita_dettaglio_table.py


示例9: codice_a_barre_articolo_table

def codice_a_barre_articolo_table(soup=None, op=None, dao=None, row=None, all=False):
    d = None
    if soup and not all:
        record = soup.codice_a_barre_articolo.get(loads(row.object))
    else:
        record = row
    if op =="DELETE":
        if all:
            d = CodiceABarreArticolo().getRecord(id=row.id)
        else:
            d = CodiceABarreArticolo().getRecord(id=loads(row.object))
        if d:
            d.delete()
        return True
    elif op == "INSERT":
        if all:
            d = CodiceABarreArticolo()
            d.id = record.id
        else:
            d = CodiceABarreArticolo().getRecord(id=loads(row.object))
    elif op == "UPDATE":
        if all:
            d = CodiceABarreArticolo().getRecord(id=row.id)
        else:
            d = CodiceABarreArticolo().getRecord(id=loads(row.object))
        if not d:
            d = CodiceABarreArticolo()
            d.id = record.id
    d.codice = record.codice
    d.id_articolo = record.id_articolo
    d.primario = record.primario

    d.persist()
    return True
开发者ID:Alwnikrotikz,项目名称:promogest,代码行数:34,代码来源:codice_a_barre_table.py


示例10: listino_table

def listino_table(soup=None, op=None, dao=None, row=None, all=False):
    d = None
    if soup and not all:
        record = soup.listino.get(loads(row.object))
    else:
        record = row
    if op =="DELETE":
        if all:
            d = Listino().getRecord(id=[row.denominazione,row.data_listino])
        else:
            d = Listino().getRecord(id=loads(row.object))
        if d:
            d.delete()
        return True
    elif op == "INSERT":
        if all:
            d = Listino()
            d.id = record.id
        else:
            d = Listino().getRecord(id=loads(row.object))
    elif op == "UPDATE":
        if all:
            d = Listino().select(id=row.id)
            if d:
                d = d[0]
        else:
            d = Listino().getRecord(id=loads(row.object))
    d.denominazione = record.denominazione
    d.descrizione = record.descrizione
    d.data_listino= record.data_listino
    d.listino_attuale = record.listino_attuale
    d.visible= record.visible
    d.persist()
    return True
开发者ID:Alwnikrotikz,项目名称:promogest,代码行数:34,代码来源:listino_table.py


示例11: fornitore_table

def fornitore_table(soup=None, op=None,dao=None, row=None, all=False):
    d = None
    if soup and not all:
        record = soup.fornitore.get(loads(row.object))
    else:
        record = row
    if op =="DELETE":
        if all:
            d = Fornitore().getRecord(id=row.id)
        else:
            d = Fornitore().getRecord(id=loads(row.object))
        if d:
            d.delete()
        return True
    elif op == "INSERT":
        if all:
            d = Fornitore()
            d.id = record.id
        else:
            d = Fornitore().getRecord(id=loads(row.object))
    elif op == "UPDATE":
        if all:
            d = Fornitore().getRecord(id=row.id)
        else:
            d = Fornitore().getRecord(id=loads(row.object))
    d.id_categoria_fornitore = record.id_categoria_fornitore
    d.id_pagamento = record.id_pagamento
    d.id_magazzino = record.id_magazzino

    d.persist()
    return True
开发者ID:Alwnikrotikz,项目名称:promogest,代码行数:31,代码来源:fornitore_table.py


示例12: test_annotated_one

    def test_annotated_one(self):
        j = join(users, addresses)._annotate({"foo": "bar"})
        query = select([addresses]).select_from(
            j
        )

        str(query)
        for prot in pickle_protocols():
            pickled_failing = serializer.dumps(
                j, prot)
            serializer.loads(pickled_failing, users.metadata, None)
开发者ID:anti-social,项目名称:sqlalchemy,代码行数:11,代码来源:test_serializer.py


示例13: listino_articolo_table

def listino_articolo_table(soup=None, op=None, dao=None, rowLocale=None, row=None, all=False):
    d = None
    if soup and not all:
        record = soup.listino_articolo.get(loads(row.object))
    else:
        record = row
    if op == "DELETE":
        if all:
            d = ListinoArticolo().getRecord(id=[row.id_articolo, row.id_listino, row.data_listino_articolo])
        else:
            d = ListinoArticolo().getRecord(id=loads(row.object))
        if d:
            d.delete()
        return True
    elif op == "INSERT":
        if all:
            d = ListinoArticolo()
            d.id_listino = record.id_listino
            d.id_articolo = record.id_articolo
            d.data_listino_articolo = record.data_listino_articolo
        else:
            d = ListinoArticolo().getRecord(id=loads(row.object))
    elif op == "UPDATE":
        if all:
            # d = ListinoArticolo().getRecord(id=[row.id_articolo,row.id_listino,row.data_listino_articolo])
            d = (
                Environment.params["session"]
                .query(ListinoArticolo)
                .get((row.id_articolo, row.id_listino, row.data_listino_articolo))
            )
        else:
            d = ListinoArticolo().getRecord(id=loads(row.object))
        if not d:
            d = ListinoArticolo()
            d.id_listino = record.id_listino
            d.id_articolo = record.id_articolo
            d.data_listino_articolo = record.data_listino_articolo
    d.prezzo_dettaglio = record.prezzo_dettaglio
    d.prezzo_ingrosso = record.prezzo_ingrosso
    d.ultimo_costo = record.ultimo_costo
    d.listino_attuale = record.listino_attuale
    a = d.persist()
    if not a:
        # g = ListinoArticolo().select(codice=record.codice)
        # if g :
        # g=g[0]
        # g.codice = g.codice+"BIS"
        # b = g.persist()
        # if not b:
        print "PROPRIO NON SO COSA FARE HO ANCHE  CAMBIATO IL CODICE"
        # listino_articolo_table(soup=soup, op=op, dao=dao, row=row, all=all)
    return True
开发者ID:Alwnikrotikz,项目名称:promogest,代码行数:52,代码来源:listino_articolo_table.py


示例14: test_query_two

 def test_query_two(self):
     q = Session.query(User).join(User.addresses).\
         filter(Address.email.like('%fred%'))
     q2 = serializer.loads(serializer.dumps(q, -1), users.metadata,
                           Session)
     eq_(q2.all(), [User(name='fred')])
     eq_(list(q2.values(User.id, User.name)), [(9, 'fred')])
开发者ID:rlugojr,项目名称:sqlalchemy,代码行数:7,代码来源:test_serializer.py


示例15: test_expression

    def test_expression(self):

        expr = select([users]).select_from(users.join(addresses)).limit(5)
        re_expr = serializer.loads(serializer.dumps(expr, -1), users.metadata, None)
        eq_(str(expr), str(re_expr))

        assert re_expr.bind is testing.db
        eq_(re_expr.execute().fetchall(), [(7, u"jack"), (8, u"ed"), (8, u"ed"), (8, u"ed"), (9, u"fred")])
开发者ID:obeattie,项目名称:sqlalchemy,代码行数:8,代码来源:test_serializer.py


示例16: test_orm_join

    def test_orm_join(self):
        from sqlalchemy.orm.util import join

        j = join(User, Address, User.addresses)

        j2 = serializer.loads(serializer.dumps(j, -1), users.metadata)
        assert j2.left is j.left
        assert j2.right is j.right
        assert j2._target_adapter._next
开发者ID:idella,项目名称:sqlalchemy,代码行数:9,代码来源:test_serializer.py


示例17: test_aliases

    def test_aliases(self):
        u7, u8, u9, u10 = Session.query(User).order_by(User.id).all()

        ualias = aliased(User)
        q = Session.query(User, ualias).join((ualias, User.id < ualias.id)).filter(User.id<9).order_by(User.id, ualias.id)

        q2 = serializer.loads(serializer.dumps(q), users.metadata, Session)
        
        eq_(list(q2.all()), [(u7, u8), (u7, u9), (u7, u10), (u8, u9), (u8, u10)])
开发者ID:jrus,项目名称:sqlalchemy,代码行数:9,代码来源:serializer.py


示例18: fornitura_table

def fornitura_table(soup=None, op=None,dao=None, row=None, all=False):
    d = None
    if soup and not all:
        record = soup.fornitura.get(loads(row.object))
    else:
        record = row
    if op =="DELETE":
        if all:
            d = Fornitura().getRecord(id=row.id)
        else:
            d = Fornitura().getRecord(id=loads(row.object))
        if d:
            d.delete()
        return True
    elif op == "INSERT":
        if all:
            d = Fornitura()
            d.id = record.id
        else:
            d = Fornitura().getRecord(id=loads(row.object))
    elif op == "UPDATE":
        if all:
            d = Fornitura().getRecord(id=row.id)
        else:
            d = Fornitura().getRecord(id=loads(row.object))

    d.codice_articolo_fornitore = record.codice_articolo_fornitore
    d.prezzo_lordo = record.prezzo_lordo
    d.prezzo_netto = record.prezzo_netto
    d.applicazione_sconti = record.applicazione_sconti
    d.scorta_minima = record.scorta_minima
    d.tempo_arrivo_merce = record.tempo_arrivo_merce
    d.fornitore_preferenziale = record.fornitore_preferenziale
    d.percentuale_iva = record.percentuale_iva
    d.data_fornitura = record.data_fornitura
    d.data_prezzo = record.data_prezzo
    d.id_fornitore = record.id_fornitore
    d.id_articolo = record.id_articolo
    d.id_multiplo = record.id_multiplo
    d.persist()
    return True
开发者ID:Alwnikrotikz,项目名称:promogest,代码行数:41,代码来源:fornitura_table.py


示例19: test_query_three

    def test_query_three(self):
        ua = aliased(User)
        q = \
            Session.query(ua).join(ua.addresses).\
               filter(Address.email.like('%fred%'))
        q2 = serializer.loads(serializer.dumps(q, -1), users.metadata,
                              Session)
        eq_(q2.all(), [User(name='fred')])

        # try to pull out the aliased entity here...
        ua_2 = q2._entities[0].entity_zero.entity
        eq_(list(q2.values(ua_2.id, ua_2.name)), [(9, 'fred')])
开发者ID:idella,项目名称:sqlalchemy,代码行数:12,代码来源:test_serializer.py


示例20: test_unicode

    def test_unicode(self):
        m = MetaData()
        t = Table(ue('\u6e2c\u8a66'), m,
                Column(ue('\u6e2c\u8a66_id'), Integer))

        expr = select([t]).where(t.c[ue('\u6e2c\u8a66_id')] == 5)

        expr2 = serializer.loads(serializer.dumps(expr, -1), m)

        self.assert_compile(
            expr2,
            ue('SELECT "\u6e2c\u8a66"."\u6e2c\u8a66_id" FROM "\u6e2c\u8a66" '
                'WHERE "\u6e2c\u8a66"."\u6e2c\u8a66_id" = :\u6e2c\u8a66_id_1'),
            dialect="default"
        )
开发者ID:Attsun1031,项目名称:sqlalchemy,代码行数:15,代码来源:test_serializer.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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