product = json.loads(p['jsondata'])
# iterates only once
for p in db(db.ul_product_cache.id>0).iterselect():
product = json.loads(p['jsondata'])
db.prototypes.update_or_insert(db.prototypes.Prototype ==
product['ProductGroup']['GroupName'],
Prototype = product['ProductGroup']['GroupName'],
origin='Unleashed')
# iterates over everything
for p in db(db.ul_product_cache.id>0).iterselect():
--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-d...@googlegroups.com
unsubscribe: web2py-develop...@googlegroups.com
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-develop...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to a topic in the Google Groups "web2py-developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py-developers/kxGnh1qlpQ8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py-develop...@googlegroups.com.
Tim Richardson CPA, Director
GrowthPath, Profit Engineers Mobile: +61 423 091 732 Office: +61 3 8678 1850 GrowthPath Pty Ltd ABN 76 133 733 963 |
--
for row in db(db.olap_sales_fact.id>0).iterselect():
(cogs_unit_price,source) = get_product_cogs(unleashed_api=unleashed_api,product_code = row.ProductCode,
warehouse=row.Warehouse,cache=cost_cache,db=db)
if cogs_unit_price:
row.update_record(COGS_Central = cogs_unit_price * -1 * row.cost_qty,COGS_Source=source)
db.commit()
It's not working, but with a different problem. I tried it in some existing code, postgresql 9.4 OS X and the binary driver I think.
I'm getting postresql errors like this:
ProgrammingError: ('ERROR', '34000', 'portal "pg8000_portal_973" does not exist')
This happens after an unpredictable number of iterations:
for row in db(db.olap_sales_fact.id>0).iterselect():
(cogs_unit_price,source) = get_product_cogs(unleashed_api=unleashed_api,product_code = row.ProductCode,
warehouse=row.Warehouse,cache=cost_cache,db=db)
if not cogs_unit_price is None:
Seems a dbapi driver bug, can you try with psycopg2?
btw: ok for updating while iterselecting, but it seems you're doing another query to get the price...... the point is multiple cursors being open and fetching the relevant resultsets........isn't "happening random" really when you get back a resutlset from your inner query ?
def testMultiSelectWithCommit(self):
db = DAL(DEFAULT_URI, check_reserved=['all'])
t0 = db.define_table('t0', Field('nn', 'integer')) for n in xrange(1, 100, 1): t0.insert(nn=n) db.commit() s = db.t0.nn.sum() tot = db(db.t0).select(s).first()[s] c = 0 for r in db(db.t0).iterselect(db.t0.ALL): db.commit() c += 1
self.assertEqual(c, db(db.t0).count()) self.assertEqual(tot * 2, db(db.t0).select(s).first()[s])
db._adapter.execute_test_query() t0.drop() db.close() return
Paolo
make speech: web2py-developers@googlegroups.com
unsubscribe: web2py-developers+unsubscribe@googlegroups.com
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-developers+unsubscribe@googlegroups.com.
--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-developers@googlegroups.com
unsubscribe: web2py-developers+unsubscribe@googlegroups.com
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-developers+unsubscribe@googlegroups.com.
Paolo
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-develop...@googlegroups.com.
--
-- mail from:GoogleGroups "web2py-developers" mailing list
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-develop...@googlegroups.com.