next up previous index
Next: What Tables are Used Up: General Database Design Previous: Guidelines   Index

Data Types

When Opus reads data from a database table, it stores the data in a Python type that is close to the type of the corresponding column in the database. The particular mapping between database types and Python types currently is defined for MySQL and should be re-defined for each additional type of database. The conversion for MySQL is:

MySQLdb FIELD_TYPE Python/numpy type
tinyint(1) bool8
short int16
int24 int32
long int32
longlong int64
float float32
double float32 (this should be float64)
decimal float64

Similarly, when writing from Python to a database, Opus converts from Python types to database-specific data types. The conversion for MySQL is:

Python/numpy type MySQL type
bool8 int(1)
int8 int(8)
int16 int(16)
int32 int(32)
int64 int(64)
float32 double
float64 decimal

Note that these conversions are not symmetrical, since multiple database types map onto a single Python type. The result is that when written back to the database, the column types may change from that of the input database table.


next up previous index
Next: What Tables are Used Up: General Database Design Previous: Guidelines   Index
info (at) urbansim.org