當前位置: 首頁>>代碼示例>>Python>>正文


Python Table.update方法代碼示例

本文整理匯總了Python中sql.Table.update方法的典型用法代碼示例。如果您正苦於以下問題:Python Table.update方法的具體用法?Python Table.update怎麽用?Python Table.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sql.Table的用法示例。


在下文中一共展示了Table.update方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_update_subselect

# 需要導入模塊: from sql import Table [as 別名]
# 或者: from sql.Table import update [as 別名]
 def test_update_subselect(self):
     t1 = Table('t1')
     t2 = Table('t2')
     query_list = t1.update([t1.c], [t2.select(t2.c, where=t2.i == t1.i)])
     query_nolist = t1.update([t1.c], t2.select(t2.c, where=t2.i == t1.i))
     for query in [query_list, query_nolist]:
         self.assertEqual(str(query),
             'UPDATE "t1" SET "c" = ('
             'SELECT "b"."c" FROM "t2" AS "b" WHERE ("b"."i" = "t1"."i"))')
         self.assertEqual(query.params, ())
開發者ID:michaelfarrell76,項目名稱:ExpertmentPlanner2,代碼行數:12,代碼來源:test_update.py

示例2: __register__

# 需要導入模塊: from sql import Table [as 別名]
# 或者: from sql.Table import update [as 別名]
    def __register__(cls, module_name):
        cursor = Transaction().cursor
        model_data = Table('ir_model_data')

        # Migration from 3.0: new tax rates
        if module_name == 'account_nl':
            for old_id, new_id in (
                    ('tva_vente_19_6', 'tva_vente_taux_normal'),
                    ('tva_vente_7', 'tva_vente_taux_intermediaire'),
                    ('tva_vente_intracommunautaire_19_6',
                        'tva_vente_intracommunautaire_taux_normal'),
                    ('tva_vente_intracommunautaire_7',
                        'tva_vente_intracommunautaire_taux_intermediaire'),
                    ('tva_achat_19_6', 'tva_achat_taux_normal'),
                    ('tva_achat_7', 'tva_achat_taux_intermediaire'),
                    ('tva_achat_intracommunautaire_19_6',
                        'tva_achat_intracommunautaire_taux_normal'),
                    ):
                cursor.execute(*model_data.select(model_data.id,
                        where=(model_data.fs_id == new_id)
                        & (model_data.module == module_name)))
                if cursor.fetchone():
                    continue
                cursor.execute(*model_data.update(
                        columns=[model_data.fs_id],
                        values=[new_id],
                        where=(model_data.fs_id == old_id)
                        & (model_data.module == module_name)))

        super(TaxTemplate, cls).__register__(module_name)
開發者ID:FvD,項目名稱:trytond_account_nl,代碼行數:32,代碼來源:account.py

示例3: test_update2

# 需要導入模塊: from sql import Table [as 別名]
# 或者: from sql.Table import update [as 別名]
 def test_update2(self):
     t1 = Table('t1')
     t2 = Table('t2')
     query = t1.update([t1.c], ['foo'], from_=[t2], where=(t1.c == t2.c))
     self.assertEqual(str(query),
         'UPDATE "t1" AS "b" SET "c" = %s FROM "t2" AS "a" '
         'WHERE ("b"."c" = "a"."c")')
     self.assertEqual(query.params, ('foo',))
開發者ID:michaelfarrell76,項目名稱:ExpertmentPlanner2,代碼行數:10,代碼來源:test_update.py

示例4: __register__

# 需要導入模塊: from sql import Table [as 別名]
# 或者: from sql.Table import update [as 別名]
 def __register__(cls, module_name):
     cursor = Transaction().cursor
     model_data = Table('ir_model_data')
     # Migration from 1.6: corrected misspelling of ounce (was once)
     cursor.execute(*model_data.update(
             columns=[model_data.fs_id],
             values=['uom_ounce'],
             where=(model_data.fs_id == 'uom_once')
             & (model_data.module == 'product')))
     super(Uom, cls).__register__(module_name)
開發者ID:aleibrecht,項目名稱:tryton-modules-ar,代碼行數:12,代碼來源:uom.py

示例5: __register__

# 需要導入模塊: from sql import Table [as 別名]
# 或者: from sql.Table import update [as 別名]
 def __register__(cls, module_name):
     cursor = Transaction().cursor
     model_data = Table('ir_model_data')
     model = Table('ir_model')
     # Migration from 1.2: packing renamed into shipment
     cursor.execute(*model_data.update(
             columns=[model_data.fs_id],
             values=[Overlay(model_data.fs_id, 'shipment',
                     Position('packing', model_data.fs_id),
                     len('packing'))],
             where=model_data.fs_id.like('%packing%')
             & (model_data.module == module_name)))
     cursor.execute(*model.update(
             columns=[model.model],
             values=[Overlay(model.model, 'shipment',
                     Position('packing', model.model),
                     len('packing'))],
             where=model.model.like('%packing%')
             & (model.module == module_name)))
     super(ShipmentInternal, cls).__register__(module_name)
開發者ID:kret0s,項目名稱:gnuhealth-live,代碼行數:22,代碼來源:shipment.py

示例6: resets

# 需要導入模塊: from sql import Table [as 別名]
# 或者: from sql.Table import update [as 別名]
 def resets(cls, dbname):
     table = Table('ir_cache')
     with Transaction().new_transaction() as transaction,\
             transaction.connection.cursor() as cursor,\
             cls._resets_lock:
         cls._resets.setdefault(dbname, set())
         for name in cls._resets[dbname]:
             cursor.execute(*table.select(table.name,
                     where=table.name == name))
             if cursor.fetchone():
                 # It would be better to insert only
                 cursor.execute(*table.update([table.timestamp],
                         [CurrentTimestamp()],
                         where=table.name == name))
             else:
                 cursor.execute(*table.insert(
                         [table.timestamp, table.name],
                         [[CurrentTimestamp(), name]]))
         cls._resets[dbname].clear()
開發者ID:coopengo,項目名稱:trytond,代碼行數:21,代碼來源:cache.py

示例7: rename

# 需要導入模塊: from sql import Table [as 別名]
# 或者: from sql.Table import update [as 別名]
 def rename(cursor, table_name, old_name, new_name, var_name):
     table = Table(table_name)
     cursor.execute(
         *table.update([getattr(table, var_name)], [new_name], where=(getattr(table, var_name) == old_name))
     )
開發者ID:coopengo,項目名稱:trytond,代碼行數:7,代碼來源:__init__.py


注:本文中的sql.Table.update方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。