本文整理匯總了Python中program.Program.get_by_kode方法的典型用法代碼示例。如果您正苦於以下問題:Python Program.get_by_kode方法的具體用法?Python Program.get_by_kode怎麽用?Python Program.get_by_kode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類program.Program
的用法示例。
在下文中一共展示了Program.get_by_kode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: import_data
# 需要導入模塊: from program import Program [as 別名]
# 或者: from program.Program import get_by_kode [as 別名]
def import_data(cls):
filenm ='kegiatan.csv'
with open(filenm, 'rb') as csvfile:
reader = csv.DictReader(csvfile, delimiter=';', quotechar='"')
for row in reader:
print row
kode = row['kode'].strip()
data = cls.get_by_kode(kode)
if not data:
data=cls()
data.kode = kode
data.created = datetime.now()
data.create_uid = 1
#data.tahun = data.created.year
#data.level_id = data.kode.count('.')+1
#data.parent_id = DBSession.query(Rekening.id).filter(Rekening.kode==data.kode[:data.kode.rfind('.')]).scalar()
data.disabled = 0
#data.defsign = 1
data.program_id=Program.get_by_kode(''.join([row['urusankd'].strip(),'.',row['programkd'].strip()])).id
data.nama = row['nama'].strip()
DBSession.add(data)
DBSession.flush()
DBSession.commit()