where ts_consumer.id_area in (36,37,38,39,40,41,42,43,68) and ts_consumer.is_byt = 0 """ # and ts_consumer.id = 402 # and ts_consumer.id = 9674 t2_consumers.execute(select) for t2_consumer in t2_consumers: consumer = Consumer() consumer.old_id = t2_consumer[2] if t2_consumer[1]: consumer.name = t2_consumer[1].decode('cp1251').encode('utf8') if t2_consumer[0]: print 'ls: %s' % t2_consumer[0] consumer.ls = t2_consumer[0].decode('cp1251').encode('utf8') consumer.type = ConsumerType.objects.get(pk=1) consumer.production_area = ProductionArea.objects.get(pk=1) consumer.save() point_select = """ select td_setuporum.id as id, -- 0 td_setuporum.working as working, -- 1 td_setuporum.deleted as deleted, -- 2 td_setuporum.id_orumtype as type, -- 3 ts_orumtype.formula as formula, -- 4 td_setuporum."POWER" as power, -- 5 td_setuporum.coef_use as ratio, -- 6 td_setuporum.hour_use as hours, -- 7 ts_point.id,
con = fdb.connect(dsn=u'/home/kirill/Документы/Калугаэнерго/T2TEST.fdb', user='******', password='******') cur = con.cursor() select = """ select first 2 ts_consumer.ls, ts_consumer.name, ts_consumer.id from ts_consumer where ts_consumer.id_area in (36,37,38,39,40,41,42,43,68) and ts_consumer.is_byt = 0 and ts_consumer.id = 9674 """ cur.execute(select) for row in cur: print 'ls: %s' % row[0] consumer = Consumer() if row[1]: consumer.name = row[1].decode('cp1251').encode('utf8') if row[0]: consumer.ls = row[0].decode('cp1251').encode('utf8') consumer.type = ConsumerType.objects.get(pk=1) consumer.production_area = ProductionArea.objects.get(pk=1) consumer.save()