[web2py] Re: Web2py dal significantly slower than raw query

2023-10-03 Thread Niphlod
Think an int, that needs to be "casted" to an int for 50k times. You can't expect an abstraction layer to be as fast as raw sql. DAL doesn't just write queries for you, it adapts the resultset to the model. 50k rows in less than 2 seconds is not that bad. On Tuesday, October 3, 2023 at 8:29:12 

[web2py] Re: Web2py dal significantly slower than raw query

2023-10-02 Thread urban....@gmail.com
12 columns, 50k rows (17k rows in the query result) cacheable=True is about 0.3s faster. The costliness of building the whole model comes (mostly) from reference types? On Monday, October 2, 2023 at 11:22:53 PM UTC+2 Niphlod wrote: > how many rows and how many columns ? the raw one is returnin

[web2py] Re: Web2py dal significantly slower than raw query

2023-10-02 Thread Niphlod
how many rows and how many columns ? the raw one is returning whatever type the underlying database structure has as it is, the pydal one is building the whole model (including references) did you try with cacheable=True in the pydal one ? it won't build update_records and delete_records, for s

[web2py] Re: Web2py dal significantly slower than raw query

2023-10-02 Thread Jim S
The only thing I can see is that the SQL needs to be 'built' by pydal, but I find it hard to believe it takes a whole second. Massimo might have to add context here. -Jim On Monday, October 2, 2023 at 1:00:19 PM UTC-5 urban@gmail.com wrote: > Sorry my bad! I mixed up the timings when edit

[web2py] Re: Web2py dal significantly slower than raw query

2023-10-02 Thread urban....@gmail.com
Sorry my bad! I mixed up the timings when editing the post. The slower timing is for the dal version. Moreover the dal version is slower even if I remove the .as_list() call. I had originally tried that. When I get the time I'll try "debugging" it by looking at the dal.py source. Asking here if a

[web2py] Re: Web2py dal significantly slower than raw query

2023-10-02 Thread Jim S
It's possible I'm reading this wrong (it is Monday morning), but .09s (DAL) is faster than 1.8s (raw SQL). Is that a typo? Or, is it my Monday-morning-brain? If your raw query is slower, could it be because you're converting to a dict instead of a list as in your dal query? -Jim On Monday,

[web2py] Web2py dal significantly slower than raw query

2023-10-02 Thread urban....@gmail.com
ids = tuple(m['id'] for m in relevant_models) raw_q = db.executesql(""" SELECT * FROM "table" WHERE ("table".ref_id" IN {}); """.format(str(ids)), as_dict=True) 1.8s ids = tuple(m['id'] for m in relevant_models) dal_q

[web2py] DAL: basic join question

2022-10-26 Thread Dave S
I have a table called pics and a table called picnotes, where the definitions are like db.define_table("pics", Field(...)) db.define_table("picnotes", Field("about", 'reference pics', Field("note", "string")) And I want to extract all rows of pics that have a note referring to them (this is a

Re: [web2py] DAL join field access

2022-09-10 Thread lucas
yes, that worked perfectly. thank you massimiliano. lucas On Saturday, September 10, 2022 at 12:43:30 PM UTC-4 Massimiliano wrote: > Hi, > > I'm not sure to have understand correctly your question, but maybe you > need to use aliases: > > fields = [ > db.table1.id.with_alias('id'), > d

Re: [web2py] DAL join field access

2022-09-10 Thread Massimiliano
Hi, I'm not sure to have understand correctly your question, but maybe you need to use aliases: fields = [ db.table1.id.with_alias('id'), db.table2.last_name.with_alias('last_name') ] db(yourquery).select(*fields) Il giorno sab 10 set 2022 alle ore 13:47 lucas ha scritto: > hello o

[web2py] DAL join field access

2022-09-10 Thread lucas
hello one and all, you know how when you do a select join and the records come back where you have to access the field values by like db.table1.id or db.table2.last_name? and i know that under the select we can do like db.table1.ALL and db.table2.last_name, but we still have to access the fie

[web2py] DAL Select(fields) puzzle

2021-08-25 Thread Rob Paire
Hi Web2py I hope someone can explains this puzzling behavior. The code below was taken from the book, and it works as given, but when I remove the "yes_or_no" condition from the field list parameters it causes a KeyError('id') error, and I don't understand why. *condition = db.person.na

Re: [web2py] DAL how to increment column value

2021-05-25 Thread Rob Paire
Ah ha!!! Excellent - that looks so much better now! I appreciate your help -Rob On Tuesday, May 25, 2021 at 4:06:04 PM UTC-4 valq...@gmail.com wrote: > > http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Expressions > > вторник, 25 мая 2021 г. в 22:36:47 UTC+3, va

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) > > > вторник, 25 мая

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 quest

Re: [web2py] DAL how to increment column value

2021-05-25 Thread Rob Paire
Hi All Thank you for the helpful comments! I am fine leaving the SQL Execute statement in place, but thought the question was worth asking. -Rob On Tuesday, May 25, 2021 at 8:06:46 AM UTC-4 Carlos Correia wrote: > Às 18:20 de 20/05/21, Rob Paire escreveu: > > Hello all, > > I am wondering if

Re: [web2py] DAL how to increment column value

2021-05-25 Thread Carlos Correia
Às 18:20 de 20/05/21, Rob Paire escreveu: Hello all, I am wondering if it's possible to use DAL update method to increment the value of table column H_REVNO in one line of code, and one trip to the database? I tried this query, and a couple of similar variations, but could not get it to work

[web2py] DAL how to increment column value

2021-05-20 Thread Rob Paire
Hello all, I am wondering if it's possible to use DAL update method to increment the value of table column H_REVNO in one line of code, and one trip to the database? I tried this query, and a couple of similar variations, but could not get it to work. db(db.KICKER.id == request.vars.kicker_id)

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

2020-10-17 Thread BigBaaadBob
It's hard to believe that I was talking about this in 2013 , but here it is again! I'm wondering if you can directly implement the Table-per-type or Shared-primary-key method of inheritance in the DAL? [image: subclass-gradstu-sc

[web2py] DAL Could not create constraint or index

2020-08-17 Thread Andrea Fae'
When I try to migrate sqlite to mssql and execute the command python web2py.py -S ITAsset -M -P (ITAsset is the name of application) I see this error ProgrammingError: ('42000', u"[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Introducing FOREIGN KEY constraint 'auth_user_created_by__

Re: [web2py] Re: reg expression use in web2py/dal?

2020-03-31 Thread Dave S
On Tuesday, March 31, 2020 at 3:38:34 AM UTC-7, Vlad wrote: > > Is there any example / doc on how to use regexp? It's just mentioned in > the book, but no details and no samples. > > It depends on your db backend and the adapter. For sqlite and the inbox-adapter, there's a python file that wr

Re: [web2py] Re: reg expression use in web2py/dal?

2020-03-31 Thread Eliezer (Vlad) Tseytkin
I mean, I understand how to use regexp for a simple pattern matching, but here I need to use the "sub" feature. What am I missing? On Tue, Mar 31, 2020, 6:38 AM Eliezer (Vlad) Tseytkin < westgate6...@gmail.com> wrote: > Is there any example / doc on how to use regexp? It's just mentioned in > the

Re: [web2py] Re: reg expression use in web2py/dal?

2020-03-31 Thread Eliezer (Vlad) Tseytkin
Is there any example / doc on how to use regexp? It's just mentioned in the book, but no details and no samples. On Tue, Mar 31, 2020, 3:35 AM Val K wrote: > re.sub() is invoked at python level not at db level. You should use > db.field.regexp(pattern) > > -- > Resources: > - http://web2py.com

[web2py] Re: reg expression use in web2py/dal?

2020-03-31 Thread Val K
Also you can pass raw sql string like db.field.on(raw_sql_string) -- 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 ar

[web2py] Re: reg expression use in web2py/dal?

2020-03-31 Thread Val K
re.sub() is invoked at python level not at db level. You should use db.field.regexp(pattern) -- 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 receive

[web2py] Re: reg expression use in web2py/dal?

2020-03-30 Thread Vlad
mething like (234)567-8901. Doesn't have to be in > any specific format, but I need to remove any non-digit characters and if > it's 10 digits - to add 1. Only then the 2 strings are comparable. > > How is it possible to do it in web2py / dal? > -- Resources: - http://web2

[web2py] reg expression use in web2py/dal?

2020-03-30 Thread Vlad
to remove any non-digit characters and if it's 10 digits - to add 1. Only then the 2 strings are comparable. How is it possible to do it in web2py / dal? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://

[web2py] DAL and temporary tables

2019-07-19 Thread Dave S
Does the DAL have any built-in support for temporary tables? I'm thinking that the best I can do here is to build the table inside my script or module (aka "model-less") and drop the table at the end. Do table files persist in "model-less"? There wouldn't be a conflict, though, any more tha

[web2py] DAL contains query with single quote (with PG backend)

2019-07-15 Thread Manuele Pesenti
Hi! I have some trouble looking for records in PostgreSQL DB filtering using "contains" DAL method with substring containing single quote... I found the raw solution sobstituting the resulting query filter "(housenumbers.city ILIKE '%sant\_olcese%' ESCAPE '\'))" with "(housenumbers.city ILIKE E'

Re: [web2py] Re: Web2py/DAL equivalent of "not in [a table]"

2019-05-14 Thread Eliezer (Vlad) Tseytkin
Oh, no problem, I've adjusted it for my case. My problem was that I wasn't aware about subqueries (_select vs. select), so that was the main take away :) On Wed, May 15, 2019, 1:28 AM Massimo Di Pierro wrote: > Something is wrong. You are searching that the id of one table is not the > id of ano

Re: [web2py] Re: Web2py/DAL equivalent of "not in [a table]"

2019-05-14 Thread Massimo Di Pierro
Something is wrong. You are searching that the id of one table is not the id of another table. But that is not a reference. On Tuesday, 14 May 2019 19:49:32 UTC-7, Vlad wrote: > > works like a charm! > thank you ! > > On Tue, May 14, 2019 at 7:16 PM Val K wrote: > >> should help: >> >> sql_str

Re: [web2py] Re: Web2py/DAL equivalent of "not in [a table]"

2019-05-14 Thread Eliezer (Vlad) Tseytkin
works like a charm! thank you ! On Tue, May 14, 2019 at 7:16 PM Val K wrote: > should help: > > sql_str = db()._select(db.tbl2.id) #note underscore before `select` > db(~db.tbl1.id.belongs(sql_str)).select(db.tbl1.id, db.tbl1.name) > > > > > > > On Wednesday, May 15, 2019 at 1:06:49 AM UTC+3, V

[web2py] Re: Web2py/DAL equivalent of "not in [a table]"

2019-05-14 Thread Val K
should help: sql_str = db()._select(db.tbl2.id) #note underscore before `select` db(~db.tbl1.id.belongs(sql_str)).select(db.tbl1.id, db.tbl1.name) On Wednesday, May 15, 2019 at 1:06:49 AM UTC+3, Vlad wrote: > > What would be an equivalent of the following? > > SELECT ID, Name > FROM Ta

[web2py] Web2py/DAL equivalent of "not in [a table]"

2019-05-14 Thread Vlad
What would be an equivalent of the following? SELECT ID, Name FROM Table1 WHERE ID NOT IN (SELECT ID FROM Table2) -- 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

Re: [web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-25 Thread João Matos
ke Postgres. This would also > avoid the silliness with the SQLite adapter bugs. We use Postgres with > Nginx and Web2py in production systems with lots of contention and it works > beautifully. But this really only matters if you have lots of users. > SQLite is very solid fo

Re: [web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-25 Thread Anthony
> > c) Anthony tried to force the transaction open with the FOR UPDATE clause, > but that doesn’t work in SQLite. > To clarify, in recognition of the fact that SQLite does not support "FOR UPDATE", the DAL attempts to simulate it with SQLite by instead preceding the select with "BEGIN IMMEDIAT

RE: [web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-24 Thread John Underhill
ve lots of users. SQLite is very solid for smaller, single-server deployments. John From: web2py@googlegroups.com On Behalf Of João Matos Sent: Sunday, March 24, 2019 2:47 PM To: web2py-users Subject: [web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end t

[web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-24 Thread Anthony
On Sunday, March 24, 2019 at 2:29:41 PM UTC-4, junderh...@qisproject.com wrote: > > João, > > No, SQLite transactions are not only ACID, the Isolation is Serializable, > which means even if the execute concurrently, > the result should be same as if they executed in series (on after the > other

[web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-24 Thread João Matos
@John I think you didn't understand the problem. I have to assign a wo_counter and a sn_counter to each new record of the wo table. To do that, I must disable any attempt to change them during the process of saving the wo record to the database. That process consists of: 1. If the user didn't sel

[web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-24 Thread junderhill
João, No, SQLite transactions are not only ACID, the Isolation is Serializable, which means even if the execute concurrently, the result should be same as if they executed in series (on after the other). What @Anthony describes should not be necessary, since you already in a transaction. http

[web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-22 Thread João Matos
@Anthony Thanks. That solves it until the SQLite code is fixed. Is there a way to question SQLite if an immediate transaction is currently open? sexta-feira, 22 de Março de 2019 às 11:38:48 UTC, Anthony escreveu: > > Looks like a bug was introduced. SQLITE does not support the SQL "FOR > UPDA

[web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-22 Thread Anthony
Looks like a bug was introduced. SQLITE does not support the SQL "FOR UPDATE" command, so the DAL simulates it by executing "BEGIN IMMEDIATE TRANSACTION", which simply starts a transaction and locks the database. Originally, the SQLite adapter did not add the "FOR UPDATE" to queries when for_up

[web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-21 Thread João Matos
Thanks, but I can't do that, because the controller is used for the grid and several other functions (onvalidation, ondelete, etc.). Besides, "locking" a record for the entire time a user is looking at it isn't a good practice. Until I found/learn a better solution with web2py, I'm using an old

[web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-21 Thread Leonel Câmara
That's weird. It seems looking at the adapter in pydal, sqlite does not start a transaction after connection like most adapters. Reading the sqlite documentation, that's probably because sqlite starts a transaction automatically as soon as anything writes to the database. So, basically, you

[web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-21 Thread João Matos
Maybe I'm not explaining myself correctly. I tested and it isn't working the way I need and explained. My test was: I put a sleep(10) between step 1 and 2. On another session I changed the record in question. Checked the changed was done. Waited for the sleep to end and then step 2 wrote over th

[web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-21 Thread João Matos
@Anthony If I try for_update=True in the 1st SELECT I get this error sqlite3.OperationalError: near "FOR": syntax error. My original code row = db.wo_counter(year_=request.now.year) My interpretation of your suggestion row = db(db.wo_counter.year_ == request.now.year).select( db.wo_counter.ye

[web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-21 Thread Anthony
On Wednesday, March 20, 2019 at 9:56:11 PM UTC-4, João Matos wrote: > > What I read about the commit/rollback "wrapping" that web2py does, it > doesn't seem to solve my problem. > > Let me explain. > I have 3 tables (sn_counter, wo_counter and wo). > The procedure I must do is the following: > 1.

[web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-21 Thread Leonel Câmara
The transaction is atomic, that means there's nothing happening in the middle. Your use case is fine. Of course, that if you give the user a form, while he's editing it, the form can be changed by others as well, in that case you need to add your own locking or check the record for modifications

[web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-21 Thread João Matos
m wo_counter or sn_counter in the middle of the commit/rollback, web2py/DAL won't stop them because no locking is in place until the commit/rollback. I am seeing this the wrong way? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.c

[web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-21 Thread Leonel Câmara
It does. A transaction is an atomic operation. https://www.geeksforgeeks.org/acid-properties-in-dbms/ -- 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

[web2py] Re: Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-20 Thread João Matos
What I read about the commit/rollback "wrapping" that web2py does, it doesn't seem to solve my problem. Let me explain. I have 3 tables (sn_counter, wo_counter and wo). The procedure I must do is the following: 1. Get the record from wo_counter table a extract the counter value (read operation),

[web2py] Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-20 Thread Leonel Câmara
Web2py always "wraps" your controller functions in a db transaction, so yes, you can do that with any database which has transactions correctly implemented. You don't need to worry about doing it manually. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://githu

[web2py] Does web2py/DAL allow for creating atomic operations (begin transaction/end transaction)?

2019-03-20 Thread João Matos
There can only be 1 transaction per record/row at the same time. 5. If anyone tries to write while a transaction is in place either receives an error or some kind of message that identifies that the record is being updated. Does anyone know if web2py/DAL allow me to do/have this? I'm using

[web2py] DAL limitby in python3

2019-02-04 Thread Maurice Waka
In python 2.7, I was able to set the limit of the last number of rows to be displayed except the exact last one as: results = db(db.answer.author == auth.user.id).select(db.answer.ALL)[-10:-1] But after switching to python 3.6, i keep getting this error: File "/home/mauricewaka/web2py/gluon/pa

Re: [web2py] DAL reference to table define after

2018-12-13 Thread Ben Duncan
Ok, if you are asking about a having multiple references to multiple tables, you can't.. For example I have the following foreign keyes defined for a AR Customer record: ALTER TABLE ar_cusmas ADD CONSTRAINT ar_cusmas_company_fkey FOREIGN KEY( company_number ) REFERENCES company (company_n

[web2py] DAL reference to table define after

2018-12-13 Thread António Ramos
How can a table X reference a field in other table Y that is defined after table X ? I have 2 tables that have fields that reference each other table fields... and i get an error regards António -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2p

Re: [web2py] DAL issues ....

2018-12-06 Thread Jim Steil
Thanks Ben On Thu, Dec 6, 2018 at 3:42 PM Ben Duncan wrote: > Controller Code: > > def company_login(): > > form = SQLFORM.factory( > Field('username', label = 'User Name', requires=IS_NOT_EMPTY()), > Field('password', 'password', label = > "Password",requires=IS_NOT_EMPTY())

Re: [web2py] DAL issues ....

2018-12-06 Thread Ben Duncan
Controller Code: def company_login(): form = SQLFORM.factory( Field('username', label = 'User Name', requires=IS_NOT_EMPTY()), Field('password', 'password', label = "Password",requires=IS_NOT_EMPTY()), Field('Company', label = 'Court ID', requires=IS_IN_DB(db,db.compa

Re: [web2py] DAL issues ....

2018-12-06 Thread Jim S
I'd love to see the final controller code if you have the time? Also, I'm curious as to why you're putting all this in the session. Why not just pass it in the dict being returned to the view? -Jim On Thursday, December 6, 2018 at 2:46:22 PM UTC-6, Ben Duncan wrote: > > Ok, YOU GUYS are awesom

Re: [web2py] DAL issues ....

2018-12-06 Thread Ben Duncan
Ok, YOU GUYS are awesome ... Your replies gave me the insight I needed ! Here is the explanation: A: in the database, the passes were for the "lookup" in the SQLFORM.factory SO there was the confusion there ... B: It seems there is a 2 passes thru the controller (which this group

Re: [web2py] DAL issues ....

2018-12-06 Thread Ben Duncan
The request.vars get set from the SQL form in the controller Removed all the COMMENTS, and in the controller put a print and changed the code: DbRows = db(db.company.company_number==Company_ID).select(db.company.company_name).first() print DbRows['company_name'] session.company_dat

[web2py] DAL issues ....

2018-12-06 Thread Val K
Maybe I don't understand something, but I think that when the controller is requested for the first time there is no any request.vars and request.vars['Company'] too. Just in case: form.process() doesn't interrupt controller execution -- Resources: - http://web2py.com - http://web2py.com/book

[web2py] DAL issues ....

2018-12-06 Thread Ben Duncan
How can something that seems so simple, be so hard? I can't seem to get a SINGLE field from the database from DAL: First is the Error Message (Or on of the many types - but the latest one), then the code What AM I doing wrong here ? Als always, thanks ... Error Message: Error ticket for "Mec"

[web2py] DAL and DB VIEWS

2018-10-29 Thread Ben Duncan
Is it possible to use predefined Postgres views inside of DAL? By views i mean (SQL code) CREATE VIEW myview AS select .. from tablea, tableb WHERE .. ); Thanks Ben Duncan -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Sour

Re: [web2py] DAL unique on multiple fields

2018-10-14 Thread Marco Mansilla
You can add it right after table definition or BEFORE validation in controller and it should work. El dom., 14 de oct. de 2018 13:03, lucas escribió: > I didn't think so, so I was making sure. I added it under onvalidation > under the controller. and also added it to the Postgres database as a

Re: [web2py] DAL unique on multiple fields

2018-10-14 Thread lucas
I didn't think so, so I was making sure. I added it under onvalidation under the controller. and also added it to the Postgres database as a custom index. thank you for verifying with me. Lucas -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/we

Re: [web2py] DAL unique on multiple fields

2018-10-14 Thread Marco Mansilla
No, but you can use requires=IS_NOT_IN_DB(table, query), if you need to make a self reference to the table you must write it after table definiton or in controller before calling the validator, and can be applied to multiple fields on the same table. Hope it helps. El dom., 14 de oct. de 2018

[web2py] DAL unique on multiple fields

2018-10-14 Thread lucas
hello one and all, is there a DAL level way to impose a constraint on a single table but unique on multiple fields within that single table? thanx in advance, lucas -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - http

[web2py] DAL with multiple foreign keyes

2018-09-24 Thread Ben Duncan
Ok, to expand my original thread:: items_purchased has a "company number", since this is a multi tenant database, that reflects what company this is part of (or division ...etc) The company number is used to define the foreign key in this table to other tables: example: fk to customers = " comp

[web2py] DAL and Foreign Keyes

2018-09-24 Thread Ben Duncan
will DAL allow multiple foreign keys on a legacy database table? i.e. : Table called item_purchased needs to have a FK to customer table as well as item table and even possibly GL COA table Thanks ... Ben Duncan -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

[web2py] DAL MySQL text type

2018-08-16 Thread Carlos Cesar Caballero Díaz
Hi guys, what kind of data type uses pydal in MySQL for "text" type?, if it is TEXT, is possible to set it for using MEDIUMTEXT or LONGTEXT? Greetings. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.goo

[web2py] DAL with UploadFS = s3 Not working with Delete and Download

2018-06-08 Thread watr
Here is my code: from fs_s3 import S3FS import datetime bucket = "pobook" region = 'ca-central-1' aws_akey = "##" aws_skey = "" myfs = S3FS( bucket, aws_access_key_id=aws_akey, aws_secret_access_key=aws_skey, regi

[web2py] DAL Attribute error

2018-05-29 Thread Maurice Waka
I moved some of my code from controller to my modules but now am getting this error: if db(db.post).isempty(): File "/usr/local/lib/python2.7/dist-packages/pydal/base.py", line 669, in __getattr__ return BasicStorage.__getattribute__(self, key) AttributeError: 'DAL' object has no attribute

Re: [web2py] DAL return all Fields

2018-05-01 Thread Maurice Waka
Thanks. Doing that already. On Tue, 1 May 2018, 18:55 Richard Vézina wrote: > I really recommand you to go through this book chapiter : > > http://web2py.com/books/default/chapter/29/02/the-python-language > > You will learn a lot of thing over which you fall right now. > > You also can use type

Re: [web2py] DAL return all Fields

2018-05-01 Thread Richard Vézina
Are you querying multiple table?? You can do a join... That way you will have all the value for every fields the only catch is that when you join to disambiguate fields names dal use table.field instead of just field as field name so it migth happen that if you call "manually" vs "programmatically"

Re: [web2py] DAL return all Fields

2018-05-01 Thread Maurice Waka
Thanks. It iterates well giving some fields data, but not all as needed. I get data from some 4 fields only. I have about 60 in some db. Plus there is this: On Tue, 1 May 2018, 16:44 Richard Vézina wrote: > for f, v in row: > > Should be > > for f, v in row.iteritems(): > > k, v for key, value,

Re: [web2py] DAL return all Fields

2018-05-01 Thread Richard Vézina
for f, v in row: Should be for f, v in row.iteritems(): k, v for key, value, but I use f instead of k because you will have field_name and value in this for loop... Richard On Mon, Apr 30, 2018 at 11:39 PM, Maurice Waka wrote: > What would f, v be. > I get this error : ValueError : too many

Re: [web2py] DAL return all Fields

2018-04-30 Thread Maurice Waka
What would f, v be. I get this error : ValueError : too many values to unpack On Mon, 30 Apr 2018, 20:38 Richard Vézina wrote: > > > On Mon, Apr 30, 2018 at 1:21 PM, Maurice Waka > wrote: > >> Sorry I tried to clarify by my new question : >> >> If I have a column with data like db.persons with

Re: [web2py] DAL return all Fields

2018-04-30 Thread Maurice Waka
Thank you. Let me work on it. Regards On Mon, 30 Apr 2018, 20:38 Richard Vézina wrote: > > > On Mon, Apr 30, 2018 at 1:21 PM, Maurice Waka > wrote: > >> Sorry I tried to clarify by my new question : >> >> If I have a column with data like db.persons with data like >> Carl >> Junior >> Maggie >>

Re: [web2py] DAL return all Fields

2018-04-30 Thread Richard Vézina
On Mon, Apr 30, 2018 at 1:21 PM, Maurice Waka wrote: > Sorry I tried to clarify by my new question : > > If I have a column with data like db.persons with data like > Carl > Junior > Maggie > Tom > Derrick > > And each column name has other fields with data such as: > persons.name persons.age per

Re: [web2py] DAL return all Fields

2018-04-30 Thread Maurice Waka
Sorry I tried to clarify by my new question : If I have a column with data like db.persons with data like Carl Junior Maggie Tom Derrick And each column name has other fields with data such as: persons.name persons.age persons.location persons.occupation persons.interests Carl 23 London Neuroscie

Re: [web2py] DAL return all Fields

2018-04-30 Thread Richard Vézina
Man this is convulated... Not sure what is in name4 "name4 is a list that contains items found in db.health.name, as well as other dbs." what items are you referring at?? What other dbs? Why are you connecting to sqlite by your own... This check is just weird : if id == item in name4: I would

Re: [web2py] DAL return all Fields

2018-04-28 Thread Maurice Waka
Thanks, but I seem to be having a challenge when returning the rows from a specific id name or number. I tried this on a different app as follows: Model: db.define_table( "health", Field('name', 'string'), Field('definition', 'text', length= 100, default="We'll

Re: [web2py] DAL return all Fields

2018-04-27 Thread Richard Vézina
for f in db.table.fields: print f or rows = db(db.fruits.id > 0).select(db.fruits.ALL) # ALL means all fields for r in rows: print(r) You can control which field you want with the previous example myfields = [f for f in db.table.fields if SOME_FILTERING_CHECK_OVER_THE_FIELD_YOU_WANT]

Re: [web2py] DAL return all Fields

2018-04-27 Thread Maurice Waka
Addendum I want a single list of the items (the data from all fields) regards On Fri, Apr 27, 2018 at 5:06 PM, Maurice Waka wrote: > There are several fields in my db such as this: > > db.define_table('fruit', Field('id', 'reference auth_user'), > Field('apple','boolean',label=T('Apple')),

[web2py] DAL return all Fields

2018-04-27 Thread Maurice Waka
There are several fields in my db such as this: db.define_table('fruit', Field('id', 'reference auth_user'), Field('apple','boolean',label=T('Apple')), Field('apricot','boolean',label=T('Apricot')), Field('cherry','boolean',label=T('Cherry')), Field('fig','boolean', label=T('Fig')), Field('lyc

[web2py] DAL query CONVERT field

2018-03-12 Thread Omicron VT
Is possible to create a query in DAL to obtain this ? SELECT * FROM table1 WHERE CONVERT(VARCHAR, field1) LIKE '%somestring%' where field1 is an INT type field ? Thanks in advance. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (So

[web2py] DAL response limit

2018-03-08 Thread Arve Lømsland
I am using web2py as REST api. The db contains of 4911 records. When we request all records with .../default/api/Employee.json it only returns 1000 records. I cant understand what is wrong? Is there a limit somewhere in DAL or in the json output? If i select with shell db_visma(db_visma.Employee)

Re: [web2py] 'DAL' object has no attribute 'db'

2018-02-07 Thread Dave S
On Wednesday, February 7, 2018 at 10:52:11 PM UTC-8, Johann Spies wrote: > > Apologies for waisting your time. The new day has opened my eyes. I > had a db.db.sometable (result of a manual copy and paste) later on in > the function which caused this db-problem. > > There is still another pr

Re: [web2py] 'DAL' object has no attribute 'db'

2018-02-07 Thread Johann Spies
Apologies for waisting your time. The new day has opened my eyes. I had a db.db.sometable (result of a manual copy and paste) later on in the function which caused this db-problem. There is still another problem but I will first try and out what is going on here. Thanks for your attention to h

Re: [web2py] 'DAL' object has no attribute 'db'

2018-02-07 Thread Johann Spies
On 7 February 2018 at 22:14, Dave S wrote: > > > I thought web2py always ran the model files before calling the controller > function, > part of the overhead of each call (and the reason for lazy tables and tables > defined in modules). > > Johann, is this function in the file named in the traceba

Re: [web2py] 'DAL' object has no attribute 'db'

2018-02-07 Thread Dave S
On Wednesday, February 7, 2018 at 6:23:55 AM UTC-8, Richard wrote: > > You define table into za_arts_and_reviews()?? > > If you it may occurs that this controller is call before db.py where you > define your db connection... > I thought web2py always ran the model files before calling the contr

Re: [web2py] 'DAL' object has no attribute 'db'

2018-02-07 Thread Richard Vézina
You define table into za_arts_and_reviews()?? If you it may occurs that this controller is call before db.py where you define your db connection... Richard On Wed, Feb 7, 2018 at 9:18 AM, Johann Spies wrote: > No. > > Regards > Johann > > On 7 February 2018 at 16:10, Richard Vézina > wrote: >

Re: [web2py] 'DAL' object has no attribute 'db'

2018-02-07 Thread Johann Spies
No. Regards Johann On 7 February 2018 at 16:10, Richard Vézina wrote: > Do you make a module function call without passing the db to it?? > > Richard > > On Wed, Feb 7, 2018 at 8:42 AM, Johann Spies wrote: >> >> Version 2.16.1-stable+timestamp.2017.11.14.05.54.25 >> >> >> Traceback (most recent

Re: [web2py] 'DAL' object has no attribute 'db'

2018-02-07 Thread Richard Vézina
Do you make a module function call without passing the db to it?? Richard On Wed, Feb 7, 2018 at 8:42 AM, Johann Spies wrote: > Version 2.16.1-stable+timestamp.2017.11.14.05.54.25 > > > Traceback (most recent call last): > File "/home/js/web2py/gluon/restricted.py", line 219, in restricted >

[web2py] 'DAL' object has no attribute 'db'

2018-02-07 Thread Johann Spies
Version 2.16.1-stable+timestamp.2017.11.14.05.54.25 Traceback (most recent call last): File "/home/js/web2py/gluon/restricted.py", line 219, in restricted exec(ccode, environment) AttributeError: 'DAL' object has no attribute 'db' During handling of the above exception, another exception o

[web2py] DAL with postgresql regexp_matches function

2018-01-29 Thread Pierre
hello everyone, Is it possible to integrate a postgresql* regexp_matches* to a dal expression query ? raw SQL working example: query = "SELECT tabla.id, tabla.name, regexp_matches(tabla.longstr, '%s', 'g') FROM tabla WHERE (tabla.longstr ~ '%s');" %(regexp,regexp) -- Resources: - http:

[web2py] DAL write permission error

2017-12-03 Thread Pbop
On windows in command prompt, running latest version of web2py When on any directory other than web2py\applications\\databases, this works fine: db = gluon.DAL('sqlite://storage.sqlite') and creates a new database or connects to an existing database. When I go db = gluon.DAL('sqlite://storag

[web2py] DAL question db(db.table.id>0,db.table.field=='x').select()

2017-09-28 Thread António Ramos
would it be more natural db(db.table.id>0,db.table.field=='x').select() instead of DAL db((db.table.id>0)&(db.table.field=='x')).select() Regards António -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.g

[web2py] DAL changes in 2.15.4 regarding Postgres - upper case table names

2017-09-13 Thread Alex Glaros
migrated from 2.14 to 2.15.4 not sure if I can explain correctly but in 2.14, DAL took my upper case table names, created lower case Postgres equivalents and could translate between them. Now I pack the exact same app in 2.14, and when Upload-and-install packed application into 2.15, it no lon

  1   2   3   4   5   6   7   >