finally I tried:
db((db.table.id >0)).select(db.table.phonenumber).find(lambda rw:
rw.phonenumber.replace("-","").replace(" ","").replace("(0)","")==caller if
rw is not None else None)
Initially this gave an error TypeError: 'NoneType' object has no attribute
'__getitem__' <https://www.ursadina.nl/admin/default/errors/gtd1#>
The problem was that the field phonenumber could also be None.
Solution: in the table definition :set default to "" and update all
existing None values to ""
Any other suggestions?
Op maandag 18 oktober 2021 om 15:37:24 UTC+2 schreef A3:
> Want to lookup a phone number in a db table
> the value to lookup is e.g. caller = "+31123456789"
> Phone numbers in db field can contain + - . and also () and is not very
> consistent.
> could look like: phonenumber = "+31-(0)123 456 789"
>
> would like something:
> db(db.table.phonenumber.like(caller)).select()
>
> Any suggestions?
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/28a9210d-19c1-4adc-88f0-0fececdfeab5n%40googlegroups.com.