Traditional SQL databases usually have support for a number of different fields. Date fields behave differently to integer fields for example. All of the fields are set using an SQL representation of the data in the form of a string and all of the queries from the database return strings.
The web.database module provides eight field types and rather than passing information to and from the database as specially formatted strings, you pass it as a python data structure. For example to set an
Integer field you would give the cursor an integer. To set a
Date field you would give the cursor a datetime.date object. The web.database cursor would do all the conversion for you.
Furthermore when you retrieve information from the database the
cursor will convert the strings recieved back into Python objects so that you never need to worry about the encodings.
This doesn't sound like too much of a big deal but because different databases handle different datatypes in slightly different ways your SQL could have different results on different databases. Programming with a web.database
cursor removes these inconsistencies.
There are currently eight field types supported and these are listed below.
||A character field taking strings of length 1|
||A string field taking strings of up to 255 characters|
||A text field for storing large amounts of text (up to 16k characters)|
||An integer field taking any integer that is a valid Python integer (but not long)|
||A float field taking Python float values|
||A date field. Takes values in the form of python datetime objects. Only stores days, months and years, any other information is trunkated. Dates from
||A time field. Takes values in the form of python datetime objects. Only stores hours, minutes and seconds, any other information is trunkated.|
||A datetime field. Takes values in the form of python datetime objects. Only stores days, months, years, hours, minutes and seconds, any other information is trunkated.|
See About this document... for information on suggesting changes.