TAILIEUCHUNG - Web to py enterprise web framework - p 20

OTHER OPERATORS 175 Other Operators web2py has other operators that provide an API to access equivalent SQL operators. Let’s define another table "log" to store security events, their timestamp and severity, where the severity is an integer number. 1 2 3 ('log', Field('event'), Field('timestamp', 'datetime'), Field('severity', 'integer')) As before, insert a few events, a "port scan", an "xss injection" and an "unauthorized login". For the sake of the example, you can log events with the same timestamp but with different severities (1, 2, 3 respectively). 1 2 3 4 5 1 import datetime now = () print (event='port scan', timestamp=now, severity=1) print (event='xss injection',. | OTHER OPERATORS 175 Other Operators 1 2 3 1 2 3 4 5 6 7 8 1 2 3 1 2 3 web2py has other operators that provide an API to access equivalent SQL operators. Let s define another table log to store security events their timestamp and severity where the severity is an integer number. log Field event Field timestamp datetime Field severity integer As before insert a few events a port scan an xss injection and an unauthorized login . For the sake of the example you can log events with the same timestamp but with different severities 1 2 3 respectively . import datetime now print event port scan timestamp now severity 1 1 print event xss injection timestamp now severity 2 2 print event unauthorized login timestamp now severity 3 3 like upper lower Fields have a like operator that you can use to match strings for row in db port .select print port scan Here port indicates a string starting with port . The percent sign character is a wild-card character that means any sequence of characters . Similarly you can use upper and lower methods to convert the value of the field to upper or lower case and you can also combine them with the like operator. for row in db .like PORT .select print port scan year month day hour minutes seconds The date and datetime fields have day month and year methods. The datetime and time fields have hour minutes and seconds methods. Here is an example 176 THE DATABASE ABSTRACTION LAYER 1 2 3 4 5 1 2 3 4 1 2 3 4 5 6 1 2 3 for row in db 2009 .select print port scan xss inj ection unauthorized login belongs The SQL IN operator is realized via the belongs method which returns true when the field value belongs to the specified set list of tuples for row in db 1 2 .select print port scan xss injection The DAL also allows a nested select as the argument .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.