[web2py] Re: count() with left join

2020-08-20 Thread valq...@gmail.com
u_cnt = db.auth_user.id.count().with_alias('user_count') user_count = db(db.auth_user).select(u_cnt, left = ...).first().user_count or just passing raw SQL as field: user_count = db(db.auth_user).select('count(id) AS user_count', left = ...).first().user_count четверг, 20 августа 2020 г.

[web2py] Re: count() with left join

2020-08-20 Thread valq...@gmail.com
t; > -Jim > > > On Thursday, August 20, 2020 at 7:28:26 PM UTC-5, valq...@gmail.com wrote: >> >> u_cnt = db.auth_user.id.count().with_alias('user_count') >> user_count = db(db.auth_user).select(u_cnt, left = >> ...).first().user_count >> >> or just passing raw SQL

[web2py] Re: How to reject request based on location

2020-10-26 Thread valq...@gmail.com
It is better to do this at front server like nginx, Apache or even at os-level. In web2py, models files are processed for each request, so you can just raise HTTP at db.py вторник, 27 октября 2020 г. в 04:52:57 UTC+3, Vlad: > I've discovered that my site is constantly bothered by weird

[web2py] Re: DAL implementation nof the Table-per-type inheritance model?

2020-10-22 Thread valq...@gmail.com
Shared pk works just fine: db.define_table( 'datetime_duration', Field('superclass','reference duration') , primarykey = ['superclass'] ) воскресенье, 18 октября 2020 г. в 02:23:00 UTC+3, BigBaaadBob: > It's hard to believe that I was talking about this in 2013 >

[web2py] Re: DAL implementation nof the Table-per-type inheritance model?

2020-10-22 Thread valq...@gmail.com
Also I fixed some bugs https://github.com/web2py/pydal/issues/548 пятница, 23 октября 2020 г. в 08:25:23 UTC+3, valq...@gmail.com: > > Shared pk works just fine: > > > db.define_table( > 'datetime_duration', > Field('superclass','reference duration') , > p

[web2py] Re: DAL implementation nof the Table-per-type inheritance model?

2020-10-22 Thread valq...@gmail.com
Also maybe useful https://github.com/web2py/pydal/issues/627 пятница, 23 октября 2020 г. в 08:32:16 UTC+3, valq...@gmail.com: > Also I fixed some bugs https://github.com/web2py/pydal/issues/548 > > пятница, 23 октября 2020 г. в 08:25:23 UTC+3, valq...@gmail.com: > >> >&

[web2py] Re: How to sort a join by count

2020-11-14 Thread valq...@gmail.com
orderby = ~person_cnt суббота, 14 ноября 2020 г. в 19:23:11 UTC+3, valq...@gmail.com: > Assuming sqlite: > person_cnt = > db.PERSON_PROJECT_PRIORITY.person_fk.count().with_alias('person_cnt') > > > prioritySet = db((db.PERSON.id <http://db.person.id/> == > PERSON

[web2py] Re: How to sort a join by count

2020-11-14 Thread valq...@gmail.com
Assuming sqlite: person_cnt = db.PERSON_PROJECT_PRIORITY.person_fk.count().with_alias('person_cnt') prioritySet = db((db.PERSON.id == PERSON-PROJECT-PRIORITY.person_fk) & (PROJECT.id == PERSON-PROJECT-PRIORITY.project_fk)).select( ..., person_cnt,

[web2py] Re: How to sort a join by count

2020-11-14 Thread valq...@gmail.com
There is no db.executesql суббота, 14 ноября 2020 г. в 19:51:52 UTC+3, alexg...@gmail.com: > sorry, did not mean direct SQL through db.executesql , meant through DAL > > On Saturday, November 14, 2020 at 8:23:11 AM UTC-8 valq...@gmail.com > wrote: > >> Assuming

[web2py] Re: How to sort a join by count

2020-11-14 Thread valq...@gmail.com
just replace *GROUP_CONCAT* with *string_agg * воскресенье, 15 ноября 2020 г. в 02:19:52 UTC+3, alexg...@gmail.com: > I have postgres. How would it look for that? > > On Saturday, November 14, 2020 at 9:03:13 AM UTC-8 valq...@gmail.com > wrote: > >> Just in case :

[web2py] Re: How to sort a join by count

2020-11-14 Thread valq...@gmail.com
Just in case : pydal doesnt support backend specific aggregate functions суббота, 14 ноября 2020 г. в 19:54:35 UTC+3, valq...@gmail.com: > There is no db.executesql > > суббота, 14 ноября 2020 г. в 19:51:52 UTC+3, alexg...@gmail.com: > >> sorry, did not mean direct SQL thr

[web2py] Re: How to sort a join by count

2020-11-14 Thread valq...@gmail.com
for example, you can use window function to get records with count in one query: db(...).select( ... , 'count(id) OVER() AS cnt' ) воскресенье, 15 ноября 2020 г. в 03:35:34 UTC+3, valq...@gmail.com: > It was in 2017 > Now you can pass to select raw-sql-strings with any expression

[web2py] Re: How to sort a join by count

2020-11-14 Thread valq...@gmail.com
I made even CTE+recursive: https://github.com/web2py/pydal/issues/627 But have no time to make a PR воскресенье, 15 ноября 2020 г. в 03:41:24 UTC+3, valq...@gmail.com: > for example, you can use window function to get records with count in > one query: > db(...).select( ... ,

[web2py] Re: How to sort a join by count

2020-11-14 Thread valq...@gmail.com
to do more advanced queries (like using string_agg) with > DAL in the meantime? > Massimo Di Pierro > Apr 12, 2017, 4:21:36 AM > to web...@googlegroups.com > You have to use db.executesql for that. Sorry. > > On Saturday, November 14, 2020 at 3:28:06 PM UTC-8 valq...@gmail.com &

Re: [web2py] Login via an link/URL

2020-11-19 Thread valq...@gmail.com
login_bare is a normal function, it is intended to login through ajax, but it cant be used in this case, since it requires raw password (not hash). I would create a table that maps hash of url (!!! Not url itself and not hash-like part of url) to user_id and then use auth.login_user as Carlos

Re: [web2py] PostgreSQL - column "COLUMN" must appear in the GROUP BY clause or be used in an aggregate function LINE 1:

2020-11-15 Thread valq...@gmail.com
Pg is not a toy like mysql It always required an explicit notation for groupby воскресенье, 15 ноября 2020 г. в 11:18:55 UTC+3, ermolaev...@gmail.com: > for grp in db((db.pay_ins_stack.ref_==db.pay_ins.id) > & (db.pay_ins.ref_ == db.deal_acc_addrs.id ) > &

[web2py] Re: github discussion feature

2021-01-08 Thread valq...@gmail.com
+1 for move to github, gg is horrible on my my gnusmas A3 пятница, 8 января 2021 г. в 02:12:00 UTC+3, Jim S: > I'd be interested in at least exploring it as an option. I'm not happy > with the new google groups at all. > > -Jim > > > On Thursday, January 7, 2021 at 5:09:50 PM UTC-6 黄祥 wrote:

[web2py] Re: version 1.21.1 infinite loop issue

2021-01-10 Thread valq...@gmail.com
When does it happen? After you have logged in? Do you get the login page? воскресенье, 10 января 2021 г. в 06:12:35 UTC+3, jimka...@yahoo.com: > No input :-( > Guess we'll need to stick with 2.20.4. Don't really have a lot of time to > put into the 2.21 migration, at least for now. :-( :-(

[web2py] Re: @auth.requires_login() on terminal

2021-01-16 Thread valq...@gmail.com
http://www.web2py.com/books/default/chapter/29/09/access-control#Access-Control-and-Basic-Authentication суббота, 16 января 2021 г. в 00:54:58 UTC+3, 黄祥: > *controllers/api.py* > @auth.requires_login() > def rows_as_json(): > if not request.env.request_method == 'GET': raise HTTP(403) >

[web2py] Re: Popolate existing DB entries on Migration with values when adding new columns

2021-01-17 Thread valq...@gmail.com
Field(..., notnull = True) does the trick суббота, 16 января 2021 г. в 21:39:00 UTC+3, ferm...@googlemail.com: > Hi, > > I need to add a new column with default values to an existing table. > > In the model file, I add > SQLField('newcolumn', type='text', default= 'Default text' ) > to the

Re: [web2py] Re: Got error when I put 'fields' as an argument to SQLFORM.grid

2021-01-28 Thread valq...@gmail.com
db.table['fieldname'] четверг, 28 января 2021 г. в 07:31:04 UTC+3, at: > It gives error: `*AttributeError('str' object has no attribute > 'tablename')*` > > The reason is that the field names are in string format not in > db.tablename.fieldname format > > > On Wed, Jan 27, 2021 at 6:30 PM

[web2py] Re: fake_migration issues

2021-01-30 Thread valq...@gmail.com
and this https://git-scm.com/download/win (portable edition) воскресенье, 31 января 2021 г. в 02:20:50 UTC+3, valq...@gmail.com: > I also used binaries for windows, but now I use this > https://winpython.github.io > > воскресенье, 31 января 2021 г. в 02:17:52 UTC+3, valq.

[web2py] Re: fake_migration issues

2021-01-30 Thread valq...@gmail.com
I dont know, try to ask Nico, since issue is still open воскресенье, 31 января 2021 г. в 01:45:28 UTC+3, snide...@gmail.com: > On Saturday, January 30, 2021 at 2:33:37 PM UTC-8 valq...@gmail.com wrote: > >> Do you use windows binaries? i.e web2py.exe? >> https://github.com/we

[web2py] Re: fake_migration issues

2021-01-30 Thread valq...@gmail.com
try to compare db.py from "fresh" welcome-app with your app. I have had a migration problem due to imports changes воскресенье, 31 января 2021 г. в 02:22:33 UTC+3, valq...@gmail.com: > and this https://git-scm.com/download/win (portable edition) > > воскресенье, 31 янв

[web2py] Re: fake_migration issues

2021-01-30 Thread valq...@gmail.com
I also used binaries for windows, but now I use this https://winpython.github.io воскресенье, 31 января 2021 г. в 02:17:52 UTC+3, valq...@gmail.com: > I dont know, try to ask Nico, since issue is still open > > воскресенье, 31 января 2021 г. в 01:45:28 UTC+3, snide...@

[web2py] Re: fake_migration issues

2021-01-30 Thread valq...@gmail.com
Do you use windows binaries? i.e web2py.exe? https://github.com/web2py/web2py/issues/2300 воскресенье, 31 января 2021 г. в 00:40:21 UTC+3, snide...@gmail.com: > > On Saturday, January 30, 2021 at 11:39:58 AM UTC-8 valq...@gmail.com > wrote: > >> >> Did you update pydal?

[web2py] Re: fake_migration issues

2021-01-30 Thread valq...@gmail.com
Did you update pydal? суббота, 30 января 2021 г. в 10:11:04 UTC+3, snide...@gmail.com: > On Monday, January 25, 2021 at 6:36:23 PM UTC-8 Dave S wrote: > >> Porting another (personal) application from my old 2.14.6 environment to >> 2.21.1., and copied both the table files and storage.sqlite

[web2py] Re: Threads in app

2021-01-30 Thread valq...@gmail.com
It is because pydal-db-connection is thread safe and as you switch to another thread there is no initialized pydal-db-connection in that thread so you can try *db._adapter.reconnect() i*n your target function (this is that py4web does on every request) And (as far as I understand) you cannot

Re: [web2py] DAL how to increment column value

2021-05-25 Thread valq...@gmail.com
db(...).update(some_field = db.some_table.some_field_or_another_field + 1) - should work ( it is a single db-query) вторник, 25 мая 2021 г. в 19:59:34 UTC+3, Rob Paire: > Hi All > Thank you for the helpful comments! I am fine leaving the SQL Execute > statement in place, but thought the

Re: [web2py] DAL how to increment column value

2021-05-25 Thread valq...@gmail.com
http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Expressions вторник, 25 мая 2021 г. в 22:36:47 UTC+3, valq...@gmail.com: > db(...).update(some_field = db.some_table.some_field_or_another_field + 1) > - should work ( it is a single db-query) > > >