[web2py] Re: Avoid colnames in executesql
The problem is that I had not installed pyodbc (I use MS SqlServer) and I was using some version of the web2py itself. Installing pyodbc works fine El jueves, 2 de diciembre de 2021 a las 11:39:39 UTC-3, Jose escribió: > I add something. If instead of making select * from MyView I doselect > MyField, AnotherFiel from MyView > > works in this way I create the dictionary with equal keys to the first > letter of each field in lowercase > > [{'m': 6, 'a': 'xx'}] > > Jose > > El jueves, 2 de diciembre de 2021 a las 11:30:37 UTC-3, Jose escribió: > >> >> Something else if I make select * from myView I get >> >> RuntimeError: Result set includes duplicate column names. Specify unique >> column names using the 'colnames' argument >> >> but I do not have duplicate fields >> >> El jueves, 2 de diciembre de 2021 a las 11:15:40 UTC-3, Jose escribió: >> >>> If I do not define colnames I get >>> >>> rows[0]['MyField'] >>> KeyError: 'MyField' >>> >>> El jueves, 2 de diciembre de 2021 a las 9:15:46 UTC-3, Jose escribió: >>> I'm migrating an old app that runs in an old version of web2py in python27. In a lot of places I use db.executesql with argument as_dict=True. The error that I am getting is that he asks me to define the colnames que es un nuevo argumento. Sometimes SQL is a query to views and others to stored procedures If I pass a list with the names of the fields it works, but it is something I want to avoid. rows = db.executesql(_sql, as_dict=True, colnames=['MyField']) # This works fine Is there any way to avoid the list with the names of the fields? Jose >>> -- 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/babadf17-3674-462c-a9a9-66d9fd14e298n%40googlegroups.com.
[web2py] Re: Avoid colnames in executesql
I add something. If instead of making select * from MyView I doselect MyField, AnotherFiel from MyView works in this way I create the dictionary with equal keys to the first letter of each field in lowercase [{'m': 6, 'a': 'xx'}] Jose El jueves, 2 de diciembre de 2021 a las 11:30:37 UTC-3, Jose escribió: > > Something else if I make select * from myView I get > > RuntimeError: Result set includes duplicate column names. Specify unique > column names using the 'colnames' argument > > but I do not have duplicate fields > > El jueves, 2 de diciembre de 2021 a las 11:15:40 UTC-3, Jose escribió: > >> If I do not define colnames I get >> >> rows[0]['MyField'] >> KeyError: 'MyField' >> >> El jueves, 2 de diciembre de 2021 a las 9:15:46 UTC-3, Jose escribió: >> >>> I'm migrating an old app that runs in an old version of web2py in >>> python27. In a lot of places I use db.executesql with argument >>> as_dict=True. The error that I am getting is that he asks me to define the >>> colnames que es un nuevo argumento. >>> >>> Sometimes SQL is a query to views and others to stored procedures >>> >>> >>> If I pass a list with the names of the fields it works, but it is >>> something I want to avoid. >>> >>> rows = db.executesql(_sql, as_dict=True, colnames=['MyField']) # This >>> works fine >>> >>> Is there any way to avoid the list with the names of the fields? >>> >>> Jose >>> >> -- 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/44af5367-5cca-48a1-8fb2-b7c38c764695n%40googlegroups.com.
[web2py] Re: Avoid colnames in executesql
Something else if I make select * from myView I get RuntimeError: Result set includes duplicate column names. Specify unique column names using the 'colnames' argument but I do not have duplicate fields El jueves, 2 de diciembre de 2021 a las 11:15:40 UTC-3, Jose escribió: > If I do not define colnames I get > > rows[0]['MyField'] > KeyError: 'MyField' > > El jueves, 2 de diciembre de 2021 a las 9:15:46 UTC-3, Jose escribió: > >> I'm migrating an old app that runs in an old version of web2py in >> python27. In a lot of places I use db.executesql with argument >> as_dict=True. The error that I am getting is that he asks me to define the >> colnames que es un nuevo argumento. >> >> Sometimes SQL is a query to views and others to stored procedures >> >> >> If I pass a list with the names of the fields it works, but it is >> something I want to avoid. >> >> rows = db.executesql(_sql, as_dict=True, colnames=['MyField']) # This >> works fine >> >> Is there any way to avoid the list with the names of the fields? >> >> Jose >> > -- 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/e10216fb-a102-4a06-8ef8-3a966e0b614fn%40googlegroups.com.
[web2py] Re: Avoid colnames in executesql
If I do not define colnames I get rows[0]['MyField'] KeyError: 'MyField' El jueves, 2 de diciembre de 2021 a las 9:15:46 UTC-3, Jose escribió: > I'm migrating an old app that runs in an old version of web2py in > python27. In a lot of places I use db.executesql with argument > as_dict=True. The error that I am getting is that he asks me to define the > colnames que es un nuevo argumento. > > Sometimes SQL is a query to views and others to stored procedures > > > If I pass a list with the names of the fields it works, but it is > something I want to avoid. > > rows = db.executesql(_sql, as_dict=True, colnames=['MyField']) # This > works fine > > Is there any way to avoid the list with the names of the fields? > > Jose > -- 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/f2cc532d-5202-4e08-b256-68e1e0ae6199n%40googlegroups.com.
[web2py] Re: DataTable() not a function
On Thursday, December 2, 2021 at 4:30:20 AM UTC-8 Dave S wrote: > That's the error I'm getting, according to Chrome's console. > > Do I have a conflict between dot-js files? > The view code is pretty simple: > > > var table; > $(document).ready(function(){ >table = $('#tableXactions').DataTable( { >"data": {{=results}} , >"columns": [ > /* { data: 'xaction.PostDate'}, */ > { data: 'xaction.Id' }, > { data: 'xaction.Amount' }, > { data: 'xaction.Expense' }, > { data: 'xaction.Tag' } > > ] > > }); > > }); > > > > > > Id > Amount > Expense > Tag > > > > > > The console shows that jquery.dataTables.min.js (and the css) is loaded > from the datatables.net cdn (1.10.19, not the latest but close). Both my > debug code and the console show that my results are as expected, so I don't > think the controller is where I messed up. > > The actual console message is > > listing:96 Uncaught TypeError: $(...).DataTable is not a function > at HTMLDocument. (listing:96) > at i (jquery.js:2) > at Object.fireWith [as resolveWith] (jquery.js:2) > at Function.ready (jquery.js:2) > at HTMLDocument.K (jquery.js:2) > (listing is my view/default/listing.html) > > I get this error even if I have no options in the DataTable() call. (And > I should be using DataTable(), not the dataTable() version, right? > Equivalent, but different return types) > > I have Roger's example, but it's much more complex than I'm ready for. > The sample on web2pyslices.com is about right, but uses a much older > version. The examples on datatables.net are snippets that they assume > you know where to put them. > > What's the fix for my mistake (or at least, what's my mistake?) > > /dps > > -- 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/03bb4594-3bc4-41e4-9a17-032526f0e348n%40googlegroups.com.
[web2py] DataTable() not a function
That's the error I'm getting, according to Chrome's console. The view code is pretty simple: var table; $(document).ready(function(){ table = $('#tableXactions').DataTable( { "data": {{=results}} , "columns": [ /* { data: 'xaction.PostDate'}, */ { data: 'xaction.Id' }, { data: 'xaction.Amount' }, { data: 'xaction.Expense' }, { data: 'xaction.Tag' } ] }); }); Id Amount Expense Tag The console shows that jquery.dataTables.min.js (and the css) is loaded from the datatables.net cdn (1.10.19, not the latest but close). Both my debug code and the console show that my results are as expected, so I don't think the controller is where I messed up. The actual console message is listing:96 Uncaught TypeError: $(...).DataTable is not a function at HTMLDocument. (listing:96) at i (jquery.js:2) at Object.fireWith [as resolveWith] (jquery.js:2) at Function.ready (jquery.js:2) at HTMLDocument.K (jquery.js:2) (listing is my view/default/listing.html) I get this error even if I have no options in the DataTable() call. (And I should be using DataTable(), not the dataTable() version, right? Equivalent, but different return types) I have Roger's example, but it's much more complex than I'm ready for. The sample on web2pyslices.com is about right, but uses a much older version. The examples on datatables.net are snippets that they assume you know where to put them. What's the fix for my mistake (or at least, what's my mistake?) /dps -- 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/a547634f-a39b-4bf1-9f56-6699692227cfn%40googlegroups.com.
[web2py] Avoid colnames in executesql
I'm migrating an old app that runs in an old version of web2py in python27. In a lot of places I use db.executesql with argument as_dict=True. The error that I am getting is that he asks me to define the colnames que es un nuevo argumento. Sometimes SQL is a query to views and others to stored procedures If I pass a list with the names of the fields it works, but it is something I want to avoid. rows = db.executesql(_sql, as_dict=True, colnames=['MyField']) # This works fine Is there any way to avoid the list with the names of the fields? Jose -- 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/218cf021-1886-4064-88d2-d0b425e0n%40googlegroups.com.
[web2py] Re: import
On Wednesday, November 17, 2021 at 1:30:31 PM UTC-8 lucas wrote: > hello one and all, > > this is not a web2py question or issue. but, since many are python > experts, i thought i'd ask. > > are there any other ways to import a module or package other then the > "import" or "from...import..." statements? i ask because i'm allowing > programming on my web2py website and i don't want any accessing packages > like os or sys. > > thank you in advance and have a great day, lucas > I believe web2py uses a custom importer, and I know of at least one other o/s project that does that (originally Py2, but now Py3). AIUI, this is a subclassing thing, but look through gluon for the actual implementation. /dps -- 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/b547a4ad-1a70-4b4b-85c0-110733eb7b80n%40googlegroups.com.
[web2py] Re: Twinning tables in DAL
On Monday, October 4, 2021 at 5:29:05 AM UTC-7 Anthony wrote: > See > http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Table-inheritance > . > > Thank you. /dps > On Saturday, October 2, 2021 at 6:21:42 PM UTC-4 snide...@gmail.com wrote: > >> I need a reminder: >> >> If I want a given table structure to be used in multiple tables >> (different instances existing at the same time), how do I set up my model? >> For small tables (lines of def) and a small number of tables, I can do a >> block copy, but is there a more, um, dynamic way to do this? >> >> /dps >> >> -- 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/d777f22e-82f2-415a-ae91-479d4f71172cn%40googlegroups.com.