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


Python DBSession.add方法代碼示例

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


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

示例1: create_payment

# 需要導入模塊: from base_models import DBSession [as 別名]
# 或者: from base_models.DBSession import add [as 別名]
 def create_payment(self, inq):
     pay, urutan = self.sismiop_create_payment(inq)
     d = pay.to_dict()
     prefix_ntp = '' 
     for fieldname in PREFIX_NTP_FIELDS: 
         prefix_ntp += d[fieldname] or '00'
     ntp = query.create_ntp(prefix_ntp)
     iso_pay = models.Payment(id=ntp)
     iso_pay.inquiry_id = inq.id
     iso_pay.propinsi = inq.propinsi
     iso_pay.kabupaten = inq.kabupaten
     iso_pay.kecamatan = inq.kecamatan
     iso_pay.kelurahan = inq.kelurahan
     iso_pay.blok = inq.blok
     iso_pay.urut = inq.urut
     iso_pay.jenis = inq.jenis
     iso_pay.tahun = inq.tahun
     iso_pay.ke = urutan
     iso_pay.kd_kanwil_bank = pay.kd_kanwil
     iso_pay.kd_kppbb_bank = pay.kd_kantor
     iso_pay.kd_bank_tunggal = '00'
     iso_pay.kd_bank_persepsi = '00'
     iso_pay.kd_tp = pay.kd_tp
     #iso_pay.channel = self.parent.from_iso.get_channel()
     iso_pay.ntb = self.parent.from_iso.get_ntb()
     iso_pay.iso_request = self.parent.from_iso.raw
     DBSession.add(iso_pay)
     DBSession.flush()
     self.set_ntp(ntp)
開發者ID:opensipkd,項目名稱:iso8583-forwarder,代碼行數:31,代碼來源:__init__.py

示例2: save

# 需要導入模塊: from base_models import DBSession [as 別名]
# 或者: from base_models.DBSession import add [as 別名]
def save():
    print('{line} -> {ip} {forwarder} {is_send} {mti} {bits}'.format(
        line=r_log.line, ip=ip, forwarder=forwarder, is_send=is_send, mti=mti,
        bits=bits))
    r_iso = Iso()
    r_iso.id = conf.nilai_int = r_log.id
    r_iso.tgl = r_log.tgl
    r_iso.jenis_id = r_log.jenis_id
    r_iso.kategori_id = r_log.kategori_id
    r_iso.ip = ip
    r_iso.forwarder = forwarder
    r_iso.is_send = is_send
    r_iso.mti = mti
    for key in bits:
        value = bits[key]
        n = str(key).zfill(3)
        fieldname = 'bit_{n}'.format(n=n)
        setattr(r_iso, fieldname, value)
    DBSession.add(r_iso)
    conf.updated = create_now()
    DBSession.add(conf)
    try:
        DBSession.flush()
    except IntegrityError as err:
        s_err = str(err)
        if s_err.find('duplicate key') > -1:
            print('  sudah ada')
            DBSession.rollback()
        else:
            raise(err)
    DBSession.commit()
開發者ID:opensipkd,項目名稱:iso8583-forwarder,代碼行數:33,代碼來源:log2iso.py

示例3: response

# 需要導入模塊: from base_models import DBSession [as 別名]
# 或者: from base_models.DBSession import add [as 別名]
 def response(self):
     if not self.rev.invoice:
         return self.parent.ack_payment_not_found()
     if not self.rev.is_paid():
         return self.parent.ack_invoice_open()
     if not self.rev.payment:
         return self.parent.ack_payment_not_found()
     if not self.is_transaction_owner():
         return self.parent.ack_payment_owner()
     iso_pay = self.rev.get_iso_payment(self.invoice_id)
     if not iso_pay:
         return self.parent.ack_payment_not_found_2()
     iso_rev = models.Reversal(payment_id=iso_pay.id)
     iso_rev.iso_request = self.parent.from_iso.raw
     DBSession.add(iso_rev)
     self.rev.set_unpaid() # flush
     self.commit()
開發者ID:opensipkd,項目名稱:iso8583-forwarder,代碼行數:19,代碼來源:__init__.py

示例4: save

# 需要導入模塊: from base_models import DBSession [as 別名]
# 或者: from base_models.DBSession import add [as 別名]
def save():
    vals = dict()
    data = r_iso.to_dict()
    for key in ('tgl', 'mti', 'bit_003', 'bit_004', 'bit_032'):
        vals[key] = data[key]
    tgl = r_iso.tgl.date()
    amount = float(r_iso.bit_004)
    if r_iso.mti == '0210':
        if r_iso.bit_003 in INQUIRY_CODES:
            method_id = 1
        else:
            method_id = 2
    else:
        method_id = 3
    method_name = methods[method_id]
    bank_id = r_iso.bit_032[-3:]
    bank_id = int(bank_id)
    bank_name = banks[bank_id]
    msg = '{id} {data} -> {tgl} {bank} {method} {amount}'.format(
            id=r_iso.id, tgl=tgl, bank=bank_name, method=method_name,
            amount=amount, data=vals)
    print(msg)
    q = DBSession.query(Summary).filter_by(
            jenis_id=r_iso.jenis_id, tgl=tgl, method_id=method_id,
            bank_id=bank_id)
    r_sum = q.first()
    if r_sum:
        r_sum.trx_count += 1
        r_sum.trx_amount += amount
    else:
        r_sum = Summary()
        r_sum.jenis_id = r_iso.jenis_id
        r_sum.tgl = tgl
        r_sum.method_id = method_id
        r_sum.bank_id = bank_id
        r_sum.trx_count = 1
        r_sum.trx_amount = amount
    DBSession.add(r_sum)
    save_conf()
開發者ID:opensipkd,項目名稱:iso8583-forwarder,代碼行數:41,代碼來源:iso-summary.py

示例5: save_conf

# 需要導入模塊: from base_models import DBSession [as 別名]
# 或者: from base_models.DBSession import add [as 別名]
def save_conf():
    conf.nilai_int = r_iso.id
    conf.updated = create_now()
    DBSession.add(conf)
    DBSession.flush()
    DBSession.commit()
開發者ID:opensipkd,項目名稱:iso8583-forwarder,代碼行數:8,代碼來源:iso-summary.py


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