[web2py] Shell - reload record from server
Hello, I have a function that I call in a shell... I load a record from a database and do some stuff.. Problem is that in the meantime the record may be modified in the server... Is there a way to reload the record from the database to track possible changes ?? (I'm using mysql) Thanks, Marcello -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Virtual field in SQLFORM.grid
I could make it work. Changed the virtual field from: Field.Virtual('total', lambda row: row.trabalho.konsulta.count()), To: Field.Virtual('total', lambda row: db((db.konsulta.trabalho_id== row.trabalho.id)).count()) Both fields work in the shell, but just the second works in the grid... Can someone explain to me why ?? On Tue, Jan 19, 2016 at 3:09 PM, Marcellowrote: > Hello, > > I have a one to many configuration, using mysql database. > I want to show a grid with the "one" table, and for each row, count the > "many". > > For that I created a total virtual field. > It works OK in the shel, for example > > But when I call the SQLFORM.grid I get an error > > Why do this happen ??? > Is there a way to get this ?? > > > Thanks > Marcello > > db.define_table( > 'trabalho', > Field('descricao','string'), > Field.Virtual('total', lambda row: row.trabalho.konsulta.count()), > ) > > db.define_table( > 'konsulta', > Field('trabalho_id', 'reference trabalho'), > Field('name','string'), > ) > > > I want to show a grid with: > grid = SQLFORM.grid(db.trabalho, editable=True, create=False, > deletable=False) > > When I call it, I get: > > > > > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Virtual field in SQLFORM.grid
Yes. I can see the tables... And yes... I can call the function.. It's working OK... Thanks... On Tue, Jan 19, 2016 at 4:39 PM, Fabiano Almeidawrote: > Hi Marcello, > > Can you see your tables in appadmin? > > And your lambda, you can create and call function to count in konsulta's > table and return the number. > > Field.Virtual('total', lambda row: kontagem(row.id)) > > > Att., > > Fabiano. > > 2016-01-19 15:09 GMT-02:00 Marcello : > >> Hello, >> >> I have a one to many configuration, using mysql database. >> I want to show a grid with the "one" table, and for each row, count the >> "many". >> >> For that I created a total virtual field. >> It works OK in the shel, for example >> >> But when I call the SQLFORM.grid I get an error >> >> Why do this happen ??? >> Is there a way to get this ?? >> >> >> Thanks >> Marcello >> >> db.define_table( >> 'trabalho', >> Field('descricao','string'), >> Field.Virtual('total', lambda row: row.trabalho.konsulta.count()), >> ) >> >> db.define_table( >> 'konsulta', >> Field('trabalho_id', 'reference trabalho'), >> Field('name','string'), >> ) >> >> >> I want to show a grid with: >> grid = SQLFORM.grid(db.trabalho, editable=True, create=False, >> deletable=False) >> >> When I call it, I get: >> >> >> >> >> -- >> 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. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: Connection timed out - mysql
My Connection timed out problem continues with trunk also. I also testes the same queries using Django. No problem. I tested many times. On Thu, Jul 12, 2012 at 9:25 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: The Assertion error comes from pymysql which ships with web2py. I just upgraded trunk to a newer version. Give it a try. It may (or my not) resolve the problem. You may want to ask the pymysql mailing list for an explanations of the error.
Re: [web2py] Re: Connection timed out - mysql
Massimo, Yes. You are right. With mysqldb worked fine. Is there any problem to use mysqldb ?? On Fri, Jul 13, 2012 at 12:52 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: To narrow down the problem. Django uses mysqldb, not pymysql. Could you try switch to mysqldb with web2py? import mysqldb from gluon.dal import MySQLAdapter MySQLAdapter.driver = mysqldb db=DAL('mysql://') Anyway, it is hard to know for sure without looking at your code. For example web2py does connection pooling and may have different settings. It could be a threading issue since you use it in modules. Which version of web2py are you using? Massimo On Friday, 13 July 2012 10:01:11 UTC-5, Marcello wrote: My Connection timed out problem continues with trunk also. I also testes the same queries using Django. No problem. I tested many times. On Thu, Jul 12, 2012 at 9:25 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: The Assertion error comes from pymysql which ships with web2py. I just upgraded trunk to a newer version. Give it a try. It may (or my not) resolve the problem. You may want to ask the pymysql mailing list for an explanations of the error.
Re: [web2py] Re: Connection timed out - mysql
No. I'll do that. Thanks again. On Fri, Jul 13, 2012 at 3:20 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: No but this should be reported to the pysqldb folks. Would you mind opening an issue there? massimo On Friday, 13 July 2012 13:10:14 UTC-5, Marcello wrote: Massimo, Yes. You are right. With mysqldb worked fine. Is there any problem to use mysqldb ?? On Fri, Jul 13, 2012 at 12:52 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: To narrow down the problem. Django uses mysqldb, not pymysql. Could you try switch to mysqldb with web2py? import mysqldb from gluon.dal import MySQLAdapter MySQLAdapter.driver = mysqldb db=DAL('mysql://') Anyway, it is hard to know for sure without looking at your code. For example web2py does connection pooling and may have different settings. It could be a threading issue since you use it in modules. Which version of web2py are you using? Massimo On Friday, 13 July 2012 10:01:11 UTC-5, Marcello wrote: My Connection timed out problem continues with trunk also. I also testes the same queries using Django. No problem. I tested many times. On Thu, Jul 12, 2012 at 9:25 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: The Assertion error comes from pymysql which ships with web2py. I just upgraded trunk to a newer version. Give it a try. It may (or my not) resolve the problem. You may want to ask the pymysql mailing list for an explanations of the error.
Re: [web2py] Select with text field
Hello, Richard, I save 2 HTML pages. SELECT processo.id, processo.na, processo.na_limpo, processo.nu, processo.nu_limpo, processo.html, processo.html1, processo.processado, processo.processado2, processo.processado_dia, processo.origem, processo.classe, processo.fase, processo.assunto, processo.instancia, processo.json, processo.conferido, processo.autuado_dia, processo.orgao_julgador, processo.relator, processo.autor, processo.reu, processo.advs, processo.autor1, processo.reu1, processo.acompanhando_dia, processo.encerrado_dia, processo.vara, processo.numero_origem, processo.ultimo_andamento_dia, processo.ultimo_andamento, processo.sentenca, processo.sentenca_dia, processo.sentenca_crc, processo.1_crc, processo.2_crc, processo.enviado_dia, processo.created_at FROM processo WHERE (processo.encerrado_dia IS NULL); One solution is select just the fields I need and not the TEXT ones... But I found that should be an easier way Thanks... On Fri, Jul 6, 2012 at 10:30 AM, Richard Vézina ml.richard.vez...@gmail.com wrote: What the nature of the data in size? Could you show us your select statment? Richard On Fri, Jul 6, 2012 at 8:41 AM, Marcello parro...@gmail.com wrote: Hello all, I have a table with two text fields. I'm trying to make a select with about 7,000 records in a console. My memory goes up, until full, and then the process is killed If I comment those text fields in the table definition and try again, it run the select without problem. In the select, I don't use those fields What cat I do to solve this ?? Thanks Marcello
Re: [web2py] Select with text field
I'm not using executesql... I'm trying just: query = q_processos.select() It seems to load all data from database... On Fri, Jul 6, 2012 at 12:40 PM, Richard Vézina ml.richard.vez...@gmail.com wrote: Are you running this request as raw SQL with executesql?? http://web2py.com/books/default/chapter/29/6#executesql If your request is slow at backend level, maybe you have a problem with your design... What is your backend? Richard On Fri, Jul 6, 2012 at 11:12 AM, Marcello Parra parro...@gmail.comwrote: Hello, Richard, I save 2 HTML pages. SELECT processo.id, processo.na, processo.na_limpo, processo.nu, processo.nu_limpo, processo.html, processo.html1, processo.processado, processo.processado2, processo.processado_dia, processo.origem, processo.classe, processo.fase, processo.assunto, processo.instancia, processo.json, processo.conferido, processo.autuado_dia, processo.orgao_julgador, processo.relator, processo.autor, processo.reu, processo.advs, processo.autor1, processo.reu1, processo.acompanhando_dia, processo.encerrado_dia, processo.vara, processo.numero_origem, processo.ultimo_andamento_dia, processo.ultimo_andamento, processo.sentenca, processo.sentenca_dia, processo.sentenca_crc, processo.1_crc, processo.2_crc, processo.enviado_dia, processo.created_at FROM processo WHERE (processo.encerrado_dia IS NULL); One solution is select just the fields I need and not the TEXT ones... But I found that should be an easier way Thanks... On Fri, Jul 6, 2012 at 10:30 AM, Richard Vézina ml.richard.vez...@gmail.com wrote: What the nature of the data in size? Could you show us your select statment? Richard On Fri, Jul 6, 2012 at 8:41 AM, Marcello parro...@gmail.com wrote: Hello all, I have a table with two text fields. I'm trying to make a select with about 7,000 records in a console. My memory goes up, until full, and then the process is killed If I comment those text fields in the table definition and try again, it run the select without problem. In the select, I don't use those fields What cat I do to solve this ?? Thanks Marcello
Re: [web2py] Re: Set table name
I pass db to module... Works fine... But I was setting (in the model): dog = 'dog12345' So.. in the module I see db and not dog... To make it work, I should pass dog also As I have many associations in this project, this wold make it almost impossible to implement On Mon, Jan 16, 2012 at 5:15 PM, Marin Pranjić marin.pran...@gmail.comwrote: On Mon, Jan 16, 2012 at 5:56 PM, Marcello parro...@gmail.com wrote: Would be great This solution works great... but it's not accessible in the modules files, because dog is not visible there... You can pass everything into modules using current object. In controller: current.db = db in module from gluon import current def module_function(): db = current.db don't do it as global, it should be inside some module_function bacause it has to be executed for every request. Marin
Re: [web2py] Re: Set table name
Thanks Ross I tried this, but did not work: - db.person[1].dog.select() raises: KeyError: 'dog' but - db.person[1].dog12345.select() works fine On Fri, Jan 13, 2012 at 10:46 AM, Ross Peoples ross.peop...@gmail.comwrote: I don't know if anyone has tried this kind of thing before. The only idea I have right now is to alias your table objects. This MIGHT work, or might make things worse :) Either way, try this and see if it works (no promises): db.define_table('person12345', Field('name'), ) db.person = db.person12345 db.define_table('dog12345', Field('name'), Field('owner', db.person) ) db.dog = db.dog12345
Re: [web2py] Re: Set table name
Marin, Thanks a lot. This solved the problem Two questions: - why the brackets ?? - is this the most elegant what to do this ?? Thanks... On Fri, Jan 13, 2012 at 11:45 AM, Marin Pranjić marin.pran...@gmail.comwrote: Try this, dog = 'dog12345' db.person[1][dog].select() On Fri, Jan 13, 2012 at 2:37 PM, Marcello Parra parro...@gmail.comwrote: Thanks Ross I tried this, but did not work: - db.person[1].dog.select() raises: KeyError: 'dog' but - db.person[1].dog12345.select() works fine On Fri, Jan 13, 2012 at 10:46 AM, Ross Peoples ross.peop...@gmail.comwrote: I don't know if anyone has tried this kind of thing before. The only idea I have right now is to alias your table objects. This MIGHT work, or might make things worse :) Either way, try this and see if it works (no promises): db.define_table('person12345', Field('name'), ) db.person = db.person12345 db.define_table('dog12345', Field('name'), Field('owner', db.person) ) db.dog = db.dog12345
Re: [web2py] Re: Set table name
Anthony, thanks very much On Fri, Jan 13, 2012 at 12:03 PM, Anthony abasta...@gmail.com wrote: Thanks a lot. This solved the problem Two questions: - why the brackets ?? Tables and fields can be accessed as properties via the usual . notation, but also via keys like a dictionary. So, db['tablename'] is equivalent to db.tablename and db.tablename['fieldname'] is equivalent to db.tablename.fieldname. - is this the most elegant what to do this ?? Probably. Anthony
[web2py] One to many question
Hello, Maybe this is a stupid question. But I could not find the answer anywhere I have, for example, 2 tables: db.define_table('account', Field('name','string'), migrate=False) db.define_table('user', Field('account_id',account), Field('name','string'), migrate=False) I get an user: u = db.user[1] If I want to get the account name of that user: u.account_id.name But I want to have it with: u.account.name Is it possible ?? Thanks Marcello
[web2py] Set table name
Hello Massimo and all, I'm trying to use web2py for several projects of mine. I always find a problem that should be solved if I could set the table name. Let me show an example... Suppose that I have this: db.define_table('person12345', Field('name')) db.define_table('dog12345', Field('name'), Field('owner', db.person)) person12345 and dog12345 are names of the tables. As they are already running projects, I can't change them... If I don't want to call a dog, dog12345 all the time, I could do this: person=db.define_table('person12345', Field('name')) dog=db.define_table('dog12345', Field('name'), Field('owner', db.person)) This should work fine. But I can't do this: person[1].dog.select() This should just work with: person[1].dog12345.select() Is there a way to do this ? Thanks...
Re: [web2py] web2py @ pycon 2011
+ 1 On Thu, Feb 17, 2011 at 12:35 PM, Richard Vézina ml.richard.vez...@gmail.com wrote: Is it possible to listen in webminar form? If yes, how much could it be? I pay for a webminar any when because I can't move to Atlanta... Richard
Re: [web2py] Re: Formstyle can be a function
OK... Thanks... I'll take a look But as I understand, I should insert this function in every SQLFORM call If this would be a default in all application is there a way that I could not duplicate code ?? On Mon, Jan 3, 2011 at 3:46 PM, mdipierro mdipie...@cs.depaul.edu wrote: No but look at the last 10 lines of SQLFORM.__init__ On Jan 3, 11:38 am, Marcello parro...@gmail.com wrote: Hello, I need to customize forms generated by SQLFORM. I saw that formstyle can be a function, and this could solve my problem. But I did not find any doc/example about this... Is there something I can start with ?? Thanks Marcello
[web2py] Legacy table
Hello, I have a legacy database, and want to access it with web2py. One table is called another_name in the database (mysql). But I want to use it in web2py as: db.define_table('person', Field('name')) I read docs, but could not figure this out Thanks for any help... Marcello
Re: [web2py] Re: Scalability of web2py?
What is the largest application running web2py today? On Wed, Dec 1, 2010 at 5:28 PM, Kuba Kucharski kuba.kuchar...@gmail.comwrote: Web2py is waiting for the first brave ONE to (be able to) GO and try to SCALE. I believe this person will get a lot of attention and resources from community and Massimo himself. Real WORLD scalable implementations are VERY CUSTOM thing. like for example: http://python.mirocommunity.org/video/1886/djangocon-2010-scaling-the-wor btw, they use apache. My point is: let's focus on our killer products that will create good enough tracking and attention to.. scale.
Re: [web2py] Re: Scalability of web2py?
Massimo, Any doc/reference about this? Thanks On Wed, Dec 1, 2010 at 11:20 PM, mdipierro mdipie...@cs.depaul.edu wrote: web2py introduces a penalty when you have lots of tables and there are some optimizations that need to be done in that case.