[web2py] Create name for additional column in query

2019-10-15 Thread Константин Комков
I have that query:
sumAuditorHours = db.a_wlp2_distrib.LC_HOURS + db.a_wlp2_distrib.SM_HOURS + 
db.a_wlp2_distrib.LB_HOURS
subjects = db((db.a_groups.id == group) & (db.a_wlp2_distrib.MODULE == 
module) & (db.a_wlp2.PARENT_ITEM != 
None)).select(db.s_disc_names.id,db.s_disc_names.FULL_NAME,db.a_wlp2.CHAIR,sumAuditorHours,orderby=db.s_disc_names.FULL_NAME,
join=[db.a_wlp2.on(db.a_groups.WLP == db.a_wlp2.WLP),
db.a_wlp2_distrib.on(db.a_wlp2.id == db.a_wlp2_distrib.WLP_ITEM),
db.s_disc_names.on(db.a_wlp2.DISC_NAME == db.s_disc_names.id)]
)
db._lastsql looks like:
SELECT s_disc_names.id, s_disc_names.FULL_NAME, a_wlp2.CHAIR, 
((a_wlp2_distrib.LC_HOURS + a_wlp2_distrib.SM_HOURS) + 
a_wlp2_distrib.LB_HOURS)
FROM a_groups
JOIN a_wlp2 ON (a_groups.WLP = a_wlp2.WLP)
JOIN a_wlp2_distrib ON (a_wlp2.id = a_wlp2_distrib.WLP_ITEM)
JOIN s_disc_names ON (a_wlp2.DISC_NAME = s_disc_names.id)
WHERE (((a_groups.id = 2277) AND (a_wlp2_distrib.MODULE = 3)) AND 
(a_wlp2.PARENT_ITEM IS NOT NULL)) ORDER BY s_disc_names.FULL_NAME
How can I add *as my_column_name?*
Now rows looks like on picture.

Thank you.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/871e5991-8ddb-4c85-a1a9-72accc1c5aba%40googlegroups.com.


Re: [web2py] Create name for additional column in query

2019-10-15 Thread Massimiliano
fields = [db.s_disc_names.id.with_alias('id'),
  db.s_disc_names.FULL_NAME-with_alias('full_name'),
  db.a_wlp2.CHAIR.with_alias('chair')
 ]
subjects = db((db.a_groups.id == group) & (db.a_wlp2_distrib.MODULE ==
module) & (db.a_wlp2.PARENT_ITEM != None)).select(*fields, ...



On Tue, Oct 15, 2019 at 1:53 PM Константин Комков 
wrote:

> I have that query:
> sumAuditorHours = db.a_wlp2_distrib.LC_HOURS + db.a_wlp2_distrib.SM_HOURS
> + db.a_wlp2_distrib.LB_HOURS
> subjects = db((db.a_groups.id == group) & (db.a_wlp2_distrib.MODULE ==
> module) & (db.a_wlp2.PARENT_ITEM != None)).select(db.s_disc_names.id
> ,db.s_disc_names.FULL_NAME,db.a_wlp2.CHAIR,sumAuditorHours,orderby=db.s_disc_names.FULL_NAME,
> join=[db.a_wlp2.on(db.a_groups.WLP == db.a_wlp2.WLP),
> db.a_wlp2_distrib.on(db.a_wlp2.id == db.a_wlp2_distrib.WLP_ITEM),
> db.s_disc_names.on(db.a_wlp2.DISC_NAME == db.s_disc_names.id)]
> )
> db._lastsql looks like:
> SELECT s_disc_names.id, s_disc_names.FULL_NAME, a_wlp2.CHAIR,
> ((a_wlp2_distrib.LC_HOURS + a_wlp2_distrib.SM_HOURS) +
> a_wlp2_distrib.LB_HOURS)
> FROM a_groups
> JOIN a_wlp2 ON (a_groups.WLP = a_wlp2.WLP)
> JOIN a_wlp2_distrib ON (a_wlp2.id = a_wlp2_distrib.WLP_ITEM)
> JOIN s_disc_names ON (a_wlp2.DISC_NAME = s_disc_names.id)
> WHERE (((a_groups.id = 2277) AND (a_wlp2_distrib.MODULE = 3)) AND
> (a_wlp2.PARENT_ITEM IS NOT NULL)) ORDER BY s_disc_names.FULL_NAME
> How can I add *as my_column_name?*
> Now rows looks like on picture.
>
> Thank you.
>
>
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/871e5991-8ddb-4c85-a1a9-72accc1c5aba%40googlegroups.com
> 
> .
>


-- 
Massimiliano

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CANPTPxKSEUfwhwi86xAKOd8-L0fjKSzG16ninN6gmeYCYTLATQ%40mail.gmail.com.


Re: [web2py] Re: py4web - will it inherit web2py structures ?

2019-10-15 Thread 'graham' via web2py-users
 Thanks Massimo, that will probably sort it out, I've had a quick look at 
bottle and should be able to amend the code appropriately.

I'll post again when it appears to be working, which, hopefully, won't be very 
long

graham


 On Tuesday, October 15, 2019, 3:38:48 AM GMT+1, Massimo Di Pierro 
 wrote:  
 
 py4web has no current and does not need it it.
from py4web import request
and just use request in your actions. Mind this is a bottlepy request, not the 
same as the web2py request object.

On Monday, 14 October 2019 06:03:14 UTC-7, graham wrote:
 I'll certainly give more details when it's working - the original web2pyslices 
posting was in 2016.

But my problem at the moment is where is 'current.request' ? That was in 
 from web2py.gluon import current
but despite importing py4web (and pydal) there seems to be no 'current' 
structure. As I mentioned the documentation isn't really helpful in this.

I'm currently using a 20190929 build (via Pycharm) and py4web itself will run.

graham On Monday, October 14, 2019, 1:26:36 AM GMT+1, Massimo Di Pierro 
 wrote:  
 
 I was not aware of it. Could you post some screen shots? maybe an example of a 
generated app?Unless you use grids it should be easy to port it to py4web.

On Sunday, 13 October 2019 17:23:37 UTC-7, graham wrote:
I used web2py some years ago and produced a program generator 
(http://www.web2pyslices.com/ slice/show/2060/generator-for- web2py) which met 
with universal disinterest...

However someone has asked whether it could work with py4web and so I have had a 
quick look at it. There are minor Python 3 issues which are easily fixed but 
when I start to look at the web2py interface I immediately come across a 
problem: the code makes us of the 'current' structure, in particular it uses 
current.request to obtain the POST data and there appears to be no such 
structure  in py4web.

I have checked the py4web documentation and it does say in the PyDAL chapter, 
under ;'Model-less applications' "...and provide necessary access to global 
scope via the current object (as described in Chapter 4)." but Chapter 4 does 
not contain any details. Perhaps this contains a lot of text from the web2py 
docs and will have corrections and more py4web content included later.

Obviously this is not of any real relevance to py4web itself but I just 
wondered whether it is intended that 'current' or an equivalent is or will be 
available in py4web or is there any simple (because I don't want to take up too 
much of your time) work around.

Thanks

graham



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/ web2py (Source code)
- https://code.google.com/p/ web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscribe@ googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/ 
msgid/web2py/fdf7c91b-a6d3- 4bd1-9d32-31c9bd7bdb37% 40googlegroups.com.
  


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/65abb443-8764-4d7b-887b-3e05abafca7c%40googlegroups.com.
  

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/2068207911.1162557.1571146378993%40mail.yahoo.com.


[web2py] Error upload file csv database

2019-10-15 Thread Kimus
Hello !!! 


I need help , I have four tables in DB, but I migrate for other domin so i 
have put the datas in DB new, but exist error foreign key incompaltible

this ocorred because when upload file example auth_user the column ID is 
modificate for other number diferents the table original 

someone could me help me, I need this ID not modify there is some way ??  

thanks :)


PS : I not speak english, so i'm so sorry :( 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/d6a35e83-24af-4bea-bfb5-123145b5bc7c%40googlegroups.com.


Re: [web2py] Create name for additional column in query

2019-10-15 Thread Massimiliano
Sorry I miss a piece:

sumAuditorHours = (db.a_wlp2_distrib.LC_HOURS + db.a_wlp2_distrib.SM_HOURS
+ db.a_wlp2_distrib.LB_HOURS)
fields = [db.s_disc_names.id.with_alias('id'),
  db.s_disc_names.FULL_NAME-with_alias('full_name'),
  db.a_wlp2.CHAIR.with_alias('chair'),
  sumAuditorHours.with_alias('auditor_hours'),
 ]
subjects = db((db.a_groups.id == group) & (db.a_wlp2_distrib.MODULE ==
module) & (db.a_wlp2.PARENT_ITEM != None)).select(*fields, ...



On Tue, Oct 15, 2019 at 3:00 PM Massimiliano  wrote:

> fields = [db.s_disc_names.id.with_alias('id'),
>   db.s_disc_names.FULL_NAME-with_alias('full_name'),
>   db.a_wlp2.CHAIR.with_alias('chair')
>  ]
> subjects = db((db.a_groups.id == group) & (db.a_wlp2_distrib.MODULE ==
> module) & (db.a_wlp2.PARENT_ITEM != None)).select(*fields, ...
>
>
>
> On Tue, Oct 15, 2019 at 1:53 PM Константин Комков 
> wrote:
>
>> I have that query:
>> sumAuditorHours = db.a_wlp2_distrib.LC_HOURS + db.a_wlp2_distrib.SM_HOURS
>> + db.a_wlp2_distrib.LB_HOURS
>> subjects = db((db.a_groups.id == group) & (db.a_wlp2_distrib.MODULE ==
>> module) & (db.a_wlp2.PARENT_ITEM != None)).select(db.s_disc_names.id
>> ,db.s_disc_names.FULL_NAME,db.a_wlp2.CHAIR,sumAuditorHours,orderby=db.s_disc_names.FULL_NAME,
>> join=[db.a_wlp2.on(db.a_groups.WLP == db.a_wlp2.WLP),
>> db.a_wlp2_distrib.on(db.a_wlp2.id == db.a_wlp2_distrib.WLP_ITEM),
>> db.s_disc_names.on(db.a_wlp2.DISC_NAME == db.s_disc_names.id)]
>> )
>> db._lastsql looks like:
>> SELECT s_disc_names.id, s_disc_names.FULL_NAME, a_wlp2.CHAIR,
>> ((a_wlp2_distrib.LC_HOURS + a_wlp2_distrib.SM_HOURS) +
>> a_wlp2_distrib.LB_HOURS)
>> FROM a_groups
>> JOIN a_wlp2 ON (a_groups.WLP = a_wlp2.WLP)
>> JOIN a_wlp2_distrib ON (a_wlp2.id = a_wlp2_distrib.WLP_ITEM)
>> JOIN s_disc_names ON (a_wlp2.DISC_NAME = s_disc_names.id)
>> WHERE (((a_groups.id = 2277) AND (a_wlp2_distrib.MODULE = 3)) AND
>> (a_wlp2.PARENT_ITEM IS NOT NULL)) ORDER BY s_disc_names.FULL_NAME
>> How can I add *as my_column_name?*
>> Now rows looks like on picture.
>>
>> Thank you.
>>
>>
>>
>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to web2py+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/web2py/871e5991-8ddb-4c85-a1a9-72accc1c5aba%40googlegroups.com
>> 
>> .
>>
>
>
> --
> Massimiliano
>


-- 
Massimiliano

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CANPTPxKc8HqS7JsU%2ByzB8FN4%2BDV7Oz8%3DR6DET98H-mD8xDojew%40mail.gmail.com.


Re: [web2py] Create name for additional column in query

2019-10-15 Thread Константин Комков
No problem, I understand that I need to use with_alias('my_column_name').
Thank you!

вт, 15 окт. 2019 г., 18:04 Massimiliano :

> Sorry I miss a piece:
>
> sumAuditorHours = (db.a_wlp2_distrib.LC_HOURS + db.a_wlp2_distrib.SM_HOURS
> + db.a_wlp2_distrib.LB_HOURS)
> fields = [db.s_disc_names.id.with_alias('id'),
>   db.s_disc_names.FULL_NAME-with_alias('full_name'),
>   db.a_wlp2.CHAIR.with_alias('chair'),
>   sumAuditorHours.with_alias('auditor_hours'),
>  ]
> subjects = db((db.a_groups.id == group) & (db.a_wlp2_distrib.MODULE ==
> module) & (db.a_wlp2.PARENT_ITEM != None)).select(*fields, ...
>
>
>
> On Tue, Oct 15, 2019 at 3:00 PM Massimiliano  wrote:
>
>> fields = [db.s_disc_names.id.with_alias('id'),
>>   db.s_disc_names.FULL_NAME-with_alias('full_name'),
>>   db.a_wlp2.CHAIR.with_alias('chair')
>>  ]
>> subjects = db((db.a_groups.id == group) & (db.a_wlp2_distrib.MODULE ==
>> module) & (db.a_wlp2.PARENT_ITEM != None)).select(*fields, ...
>>
>>
>>
>> On Tue, Oct 15, 2019 at 1:53 PM Константин Комков 
>> wrote:
>>
>>> I have that query:
>>> sumAuditorHours = db.a_wlp2_distrib.LC_HOURS +
>>> db.a_wlp2_distrib.SM_HOURS + db.a_wlp2_distrib.LB_HOURS
>>> subjects = db((db.a_groups.id == group) & (db.a_wlp2_distrib.MODULE ==
>>> module) & (db.a_wlp2.PARENT_ITEM != None)).select(db.s_disc_names.id
>>> ,db.s_disc_names.FULL_NAME,db.a_wlp2.CHAIR,sumAuditorHours,orderby=db.s_disc_names.FULL_NAME,
>>> join=[db.a_wlp2.on(db.a_groups.WLP == db.a_wlp2.WLP),
>>> db.a_wlp2_distrib.on(db.a_wlp2.id == db.a_wlp2_distrib.WLP_ITEM),
>>> db.s_disc_names.on(db.a_wlp2.DISC_NAME == db.s_disc_names.id)]
>>> )
>>> db._lastsql looks like:
>>> SELECT s_disc_names.id, s_disc_names.FULL_NAME, a_wlp2.CHAIR,
>>> ((a_wlp2_distrib.LC_HOURS + a_wlp2_distrib.SM_HOURS) +
>>> a_wlp2_distrib.LB_HOURS)
>>> FROM a_groups
>>> JOIN a_wlp2 ON (a_groups.WLP = a_wlp2.WLP)
>>> JOIN a_wlp2_distrib ON (a_wlp2.id = a_wlp2_distrib.WLP_ITEM)
>>> JOIN s_disc_names ON (a_wlp2.DISC_NAME = s_disc_names.id)
>>> WHERE (((a_groups.id = 2277) AND (a_wlp2_distrib.MODULE = 3)) AND
>>> (a_wlp2.PARENT_ITEM IS NOT NULL)) ORDER BY s_disc_names.FULL_NAME
>>> How can I add *as my_column_name?*
>>> Now rows looks like on picture.
>>>
>>> Thank you.
>>>
>>>
>>>
>>> --
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to web2py+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/web2py/871e5991-8ddb-4c85-a1a9-72accc1c5aba%40googlegroups.com
>>> 
>>> .
>>>
>>
>>
>> --
>> Massimiliano
>>
>
>
> --
> Massimiliano
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/GiDioBnqHts/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/CANPTPxKc8HqS7JsU%2ByzB8FN4%2BDV7Oz8%3DR6DET98H-mD8xDojew%40mail.gmail.com
> 
> .
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CAM7z-VkhUHg2aeYn4vML31JHAa3rGMq2zoyDBJ1xGGyZtseChg%40mail.gmail.com.


[web2py] multi tables count

2019-10-15 Thread Patito Feo
Hi,

Ive been trying many ways of getting this right,

db.define_table('pedidos',
Field('fecha',  type='date' ),
Field('cliente', ),
Field('pares', ),
Field('estado', ),
Field('noitems', ),
Field('notapedido', ),
Field('tipopedido', ),
Field('vendedor', ),
   )

db.define_table('itemspedidos',
Field('NUM_ITEM', 'integer'),
Field('COD_PEDI', 'integer'),
Field('COD_CLIE', ),
Field('OD_SUCU' ),
Field('TIP_PEDI', ),
Field('TIP_BASE', ),
Field('COD_REFE', ),
Field('COD_COLO', ),
Field('CAN_PEDI', 'integer' ),
Field('CAMPO_01', 'integer' ),
Field('CAMPO_02', 'integer' ),
Field('CAMPO_03', 'integer' ),
Field('CAMPO_04', 'integer' ),
Field('CAMPO_05', 'integer' ),
Field('CAMPO_06', 'integer' ),
Field('CAMPO_07', 'integer' ),
Field('CAMPO_S1', 'integer' ),
Field('CAMPO_S2', 'integer' ),
Field('CAMPO_S3', 'integer' ),
Field('CAMPO_S4', 'integer' ),
Field('CAMPO_S5', 'integer'),
Field('CAMPO_S6',  'integer'),
Field('CAMPO_S7', 'integer' ),
Field('CAN_DOCE', 'integer' ),
   )

I need to find pedidos by month using pedidos.fecha and to count how many 
itemspedidos.COD_REFE are per month by each itemspedidos.COD_REFE which is 
the item reference.

rows=db( db.pedidos.fecha.year() == '2019' )( db.itemspedidos.COD_PEDI == 
db.pedidos.id ).select( db.itemspedidos.COD_REFE, 
db.itemspedidos.COD_REFE.count( distinct=True ), db.pedidos.fecha.month(), 
orderby=db.pedidos.fecha.month(), groupby=db.pedidos.fecha.month(), )

This is a sample of what i get:

itemspedidos.COD_REFE EXTRACT(month FROM "pedidos"."fecha")
132 MILAN 4
132 MILAN 4
132 MILAN 4
113 SARA 4
122 CLAUDIA NIÑA 4
122 CLAUDIA NIÑA 4
122 CLAUDIA NIÑA 4
122 CLAUDIA NIÑA 4

As you can see i get the month and the itemspedidos.COD_REFE, but im unable 
to count by itemspedidos.COD_REFE per month and per unique 
itemspedidos.COD_REFE.

Some advice would be nice,


Thanks in advance


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/b1c42e0f-487b-4796-84ca-702298c399f8%40googlegroups.com.


Re: [web2py] multi tables count

2019-10-15 Thread Massimiliano
I don't understand exactly what you mean, but maybe, you want to count
itemspedidos.id grouping by [db.pedidos.fecha.month(),
db.itemspedidos.COD_REFE]

rows=db( (db.pedidos.fecha.year() == '2019' )&( db.itemspedidos.COD_PEDI ==
db.pedidos.id )).select( db.itemspedidos.COD_REFE,
db.itemspedidos.id.count(), db.pedidos.fecha.month(),
orderby=db.pedidos.fecha.month(), groupby=[db.pedidos.fecha.month(),
db.itemspedidos.COD_REFE])

On Tue, Oct 15, 2019 at 10:07 PM Patito Feo  wrote:

> Hi,
>
> Ive been trying many ways of getting this right,
>
> db.define_table('pedidos',
> Field('fecha',  type='date' ),
> Field('cliente', ),
> Field('pares', ),
> Field('estado', ),
> Field('noitems', ),
> Field('notapedido', ),
> Field('tipopedido', ),
> Field('vendedor', ),
>)
>
> db.define_table('itemspedidos',
> Field('NUM_ITEM', 'integer'),
> Field('COD_PEDI', 'integer'),
> Field('COD_CLIE', ),
> Field('OD_SUCU' ),
> Field('TIP_PEDI', ),
> Field('TIP_BASE', ),
> Field('COD_REFE', ),
> Field('COD_COLO', ),
> Field('CAN_PEDI', 'integer' ),
> Field('CAMPO_01', 'integer' ),
> Field('CAMPO_02', 'integer' ),
> Field('CAMPO_03', 'integer' ),
> Field('CAMPO_04', 'integer' ),
> Field('CAMPO_05', 'integer' ),
> Field('CAMPO_06', 'integer' ),
> Field('CAMPO_07', 'integer' ),
> Field('CAMPO_S1', 'integer' ),
> Field('CAMPO_S2', 'integer' ),
> Field('CAMPO_S3', 'integer' ),
> Field('CAMPO_S4', 'integer' ),
> Field('CAMPO_S5', 'integer'),
> Field('CAMPO_S6',  'integer'),
> Field('CAMPO_S7', 'integer' ),
> Field('CAN_DOCE', 'integer' ),
>)
>
> I need to find pedidos by month using pedidos.fecha and to count how many
> itemspedidos.COD_REFE are per month by each itemspedidos.COD_REFE which is
> the item reference.
>
> rows=db( db.pedidos.fecha.year() == '2019' )( db.itemspedidos.COD_PEDI ==
> db.pedidos.id ).select( db.itemspedidos.COD_REFE,
> db.itemspedidos.COD_REFE.count( distinct=True ), db.pedidos.fecha.month(),
> orderby=db.pedidos.fecha.month(), groupby=db.pedidos.fecha.month(), )
>
> This is a sample of what i get:
>
> itemspedidos.COD_REFE EXTRACT(month FROM "pedidos"."fecha")
> 132 MILAN 4
> 132 MILAN 4
> 132 MILAN 4
> 113 SARA 4
> 122 CLAUDIA NIÑA 4
> 122 CLAUDIA NIÑA 4
> 122 CLAUDIA NIÑA 4
> 122 CLAUDIA NIÑA 4
>
> As you can see i get the month and the itemspedidos.COD_REFE, but im
> unable to count by itemspedidos.COD_REFE per month and per unique
> itemspedidos.COD_REFE.
>
> Some advice would be nice,
>
>
> Thanks in advance
>
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/b1c42e0f-487b-4796-84ca-702298c399f8%40googlegroups.com
> 
> .
>


-- 
Massimiliano

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CANPTPxLbsgRpR6YG0r-Ne2ehbAJC5bU%2BJt1adNRW3UmiVgaeTg%40mail.gmail.com.


Re: [web2py] multi tables count

2019-10-15 Thread Patito Feo
Well, I just tried your reply and it works. I didnt know i was able to 
groupby mutiple fields and the count should be the id. One complete week 
stuck in this. 


Thanks a lot.



El martes, 15 de octubre de 2019, 15:52:25 (UTC-5), Massimiliano escribió:
>
> I don't understand exactly what you mean, but maybe, you want to count 
> itemspedidos.id grouping by [db.pedidos.fecha.month(), 
> db.itemspedidos.COD_REFE]
>
> rows=db( (db.pedidos.fecha.year() == '2019' )&( db.itemspedidos.COD_PEDI 
> == db.pedidos.id )).select( db.itemspedidos.COD_REFE, 
> db.itemspedidos.id.count(), db.pedidos.fecha.month(), 
> orderby=db.pedidos.fecha.month(), groupby=[db.pedidos.fecha.month(), 
> db.itemspedidos.COD_REFE])
>
> On Tue, Oct 15, 2019 at 10:07 PM Patito Feo  > wrote:
>
>> Hi,
>>
>> Ive been trying many ways of getting this right,
>>
>> db.define_table('pedidos',
>> Field('fecha',  type='date' ),
>> Field('cliente', ),
>> Field('pares', ),
>> Field('estado', ),
>> Field('noitems', ),
>> Field('notapedido', ),
>> Field('tipopedido', ),
>> Field('vendedor', ),
>>)
>>
>> db.define_table('itemspedidos',
>> Field('NUM_ITEM', 'integer'),
>> Field('COD_PEDI', 'integer'),
>> Field('COD_CLIE', ),
>> Field('OD_SUCU' ),
>> Field('TIP_PEDI', ),
>> Field('TIP_BASE', ),
>> Field('COD_REFE', ),
>> Field('COD_COLO', ),
>> Field('CAN_PEDI', 'integer' ),
>> Field('CAMPO_01', 'integer' ),
>> Field('CAMPO_02', 'integer' ),
>> Field('CAMPO_03', 'integer' ),
>> Field('CAMPO_04', 'integer' ),
>> Field('CAMPO_05', 'integer' ),
>> Field('CAMPO_06', 'integer' ),
>> Field('CAMPO_07', 'integer' ),
>> Field('CAMPO_S1', 'integer' ),
>> Field('CAMPO_S2', 'integer' ),
>> Field('CAMPO_S3', 'integer' ),
>> Field('CAMPO_S4', 'integer' ),
>> Field('CAMPO_S5', 'integer'),
>> Field('CAMPO_S6',  'integer'),
>> Field('CAMPO_S7', 'integer' ),
>> Field('CAN_DOCE', 'integer' ),
>>)
>>
>> I need to find pedidos by month using pedidos.fecha and to count how many 
>> itemspedidos.COD_REFE are per month by each itemspedidos.COD_REFE which is 
>> the item reference.
>>
>> rows=db( db.pedidos.fecha.year() == '2019' )( db.itemspedidos.COD_PEDI == 
>> db.pedidos.id ).select( db.itemspedidos.COD_REFE, 
>> db.itemspedidos.COD_REFE.count( distinct=True ), db.pedidos.fecha.month(), 
>> orderby=db.pedidos.fecha.month(), groupby=db.pedidos.fecha.month(), )
>>
>> This is a sample of what i get:
>>
>> itemspedidos.COD_REFE EXTRACT(month FROM "pedidos"."fecha")
>> 132 MILAN 4
>> 132 MILAN 4
>> 132 MILAN 4
>> 113 SARA 4
>> 122 CLAUDIA NIÑA 4
>> 122 CLAUDIA NIÑA 4
>> 122 CLAUDIA NIÑA 4
>> 122 CLAUDIA NIÑA 4
>>
>> As you can see i get the month and the itemspedidos.COD_REFE, but im 
>> unable to count by itemspedidos.COD_REFE per month and per unique 
>> itemspedidos.COD_REFE.
>>
>> Some advice would be nice,
>>
>>
>> Thanks in advance
>>
>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/web2py/b1c42e0f-487b-4796-84ca-702298c399f8%40googlegroups.com
>>  
>> 
>> .
>>
>
>
> -- 
> Massimiliano
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/02b803a2-317f-4d3c-bcd0-450337f9f169%40googlegroups.com.


[web2py] Re: About response.toolbar

2019-10-15 Thread Massimo Di Pierro
Those are queries made by your app to the database within the same request 
that serves the toolbar. This looks like a registration page because of 
INSERT in auth_user. It does make a lot of select. you may want to simplify 
your code and use caching, else this page is going to be very slow.

I do not understand your last question.


On Monday, 14 October 2019 23:52:06 UTC-7, Константин Комков wrote:

> What I see on picture? What is that queries?
> Are there way to put toolbar buttons in string?
>
> Thank you.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/afae6822-16ce-4ed0-b858-ef1634f3deee%40googlegroups.com.


[web2py] Re: Error upload file csv database

2019-10-15 Thread Massimo Di Pierro
Do you have the original database. If you do you should export it from the 
web2py shell with db.export_to_csv_file and reimport it with 
db.import_from_csv_file. This is documented in the manual. The import will 
automatically fix your keys.

If you use postgres you can use pgdump and pgrestore.

If you do not have the original database then this may be hopeless.

Massimo




P.S. I do not speak english very well either but as long as we understand 
each other we are fine. :-)


On Tuesday, 15 October 2019 06:40:24 UTC-7, Kimus wrote:
>
> Hello !!! 
>
>
> I need help , I have four tables in DB, but I migrated for other domain so 
> i stored the information in another DB, but it returned error, inconpatible 
> foreing key. 
> This ocorred because when uploaded the file "example auth_user" the column 
> ID is modifyed to other number, that is diferent from the original table.
>
> someone could me help me, please, I need this ID to be not modifyed,  
> there is some way ??  
>
> thanks :)
>
>
> PS : I do not speak english, so i'm so sorry :( 
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/63bbf95f-7fec-4486-9b06-3a7d22ba5645%40googlegroups.com.


Re: [web2py] db.import_from_csv_file in python3

2019-10-15 Thread Massimo Di Pierro
Can you please open a pydal ticket? I can fix this over the week-end.

On Monday, 14 October 2019 01:54:41 UTC-7, Mamisoa Andriantafika wrote:
>
> It seems to be related with the "blob" type where python 2 accept also 
> string type while python 3 expect byte type.
>
> When I delete the row which contains the blob with string inside, 
> exporting function works.
>
> Le dimanche 13 octobre 2019 19:05:58 UTC+2, Mamisoa Andriantafika a écrit :
>>
>> Hi,
>>
>> I can't seem to export the db using db.import_from_csv_file in python3. 
>> It is working in python 2.
>>
>> It seems to be a problem with one of the image or blob field in a table ? 
>> Actually there is only on blob field populated with a b64 image file, but 
>> yet no image file in upload field.
>>
>> db.define_table('photo_id',
>> Field('imagefile', 'upload'),
>> Field('b64img','blob'),
>> Field('id_auth_user', 'reference auth_user', writable = False, 
>> readable = False),
>> auth.signature)
>>
>> Billet d'erreur for "ECapp19" Identifiant du Billet 
>>
>> 127.0.0.1.2019-10-13.18-48-04.b589bcc3-5676-49ce-a64e-a9b005d108b1
>>  a bytes-like object is required, not 'str' Version 
>> web2py™ Version 2.18.5-stable+timestamp.2019.04.08.04.22.03 
>> Python Python 3.6.8: /usr/bin/python3 (prefix: /usr) Traceback 
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>> 16.
>>
>> Traceback (most recent call last):
>>   File "/home/www-data/web2py/gluon/restricted.py", line 219, in restricted
>> exec(ccode, environment)
>>   File "/home/www-data/web2py/applications/ECapp19/controllers/manage.py" 
>> , line 
>> 135, in 
>>   File "/home/www-data/web2py/gluon/globals.py", line 421, in 
>> self._caller = lambda f: f()
>>   File "/home/www-data/web2py/applications/ECapp19/controllers/manage.py" 
>> , line 
>> 47, in save_db
>> db.export_to_csv_file(dumpfile)
>>   File "/home/www-data/web2py/gluon/packages/dal/pydal/base.py", line 852, 
>> in export_to_csv_file
>> ofile, *args, **kwargs)
>>   File "/home/www-data/web2py/gluon/packages/dal/pydal/objects.py", line 
>> 2811, in export_to_csv_file
>> value = base64.b64encode(value)
>>   File "/usr/lib/python3.6/base64.py", line 58, in b64encode
>> encoded = binascii.b2a_base64(s, newline=False)
>> TypeError: a bytes-like object is required, not 'str'
>>
>> Error snapshot [image: help] 
>> 
>>  
>>
>> TypeError(a bytes-like object is required, not 'str') 
>>
>> inspect attributes 
>> Frames 
>>
>>- 
>>
>>*File /home/www-data/web2py/gluon/restricted.py in restricted at line 
>>219* code arguments variables 
>>- 
>>
>>*File 
>>/home/www-data/web2py/applications/ECapp19/controllers/manage.py in 
>> at line 135* code arguments variables 
>>- 
>>
>>*File /home/www-data/web2py/gluon/globals.py in  at line 421* 
>>code arguments variables 
>>- 
>>
>>*File 
>>/home/www-data/web2py/applications/ECapp19/controllers/manage.py in 
>> save_db 
>>at line 47* code arguments variables 
>>- 
>>
>>*File /home/www-data/web2py/gluon/packages/dal/pydal/base.py in 
>>export_to_csv_file at line 852* code arguments variables 
>>- 
>>
>>*File /home/www-data/web2py/gluon/packages/dal/pydal/objects.py in 
>>export_to_csv_file at line 2811* code arguments variables 
>>- 
>>
>>*File /usr/lib/python3.6/base64.py in b64encode at line 58* code 
>>arguments variables 
>>Function argument list 
>>
>>
>> (s='data:image/jpeg;base64,/9j/4AAQSkZJRgABAgEBLAEsA...xIWdmOeSSeTn/AOvSJnOM8j9KcWyMjgU5DgHuakVjjgV//9k=',
>>  
>>altchars=None)
>>Code listing 
>>
>>53.
>>54.
>>55.
>>56.
>>57.
>>58.
>>59.
>>60.
>>61.
>>62.
>>
>>
>>Optional altchars should be a byte string of length 2 which specifies 
>> an
>>alternative alphabet for the '+' and '/' characters.  This allows an
>>application to e.g. generate url or filesystem safe Base64 strings.
>>"""
>>encoded = binascii.b2a_base64(s, newline=False)
>>if altchars is not None:
>>assert len(altchars) == 2, repr(altchars)
>>return encoded.translate(bytes.maketrans(b'+/', altchars))
>>return encoded
>>
>>Variables 
>>encoded undefined 
>>global binascii  
>>binascii.b2a_base64  
>>s 
>>
>> 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAgEBLAEsA...xIWdmOeSSeTn/AOvSJnOM8j9KcWyMjgU5DgHuakVjjgV//9k='
>>  
>>newline undefined
>>
>>
>> Any ideas?
>>
>> Mamisoa
>>
>>
>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Sour