Public Member Functions

MGT::Sql::SqlNumpyTypeMap Class Reference

List of all members.

Public Member Functions

def __init__
def dtype

Detailed Description

Map between SQL data types and NumPy data types.
Precision in digits vs number of bytes for integer NUMBER types are taken
from MySQL reference (but should be universal)
http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html
and from SQL code:
db.ddl("create table tmp_types (f_bool bool, f_tinyint tinyint, f_smallint smallint, f_med mediumint, f_int int,"+
" f_big bigint, f_char char(5), f_float float)",dropList=["table tmp_types"])
curs = db.execute("select * from tmp_types limit 1")
print curs.description

Constructor & Destructor Documentation

def MGT::Sql::SqlNumpyTypeMap::__init__ (   self,
  dbapi 
)
@param dbapi - Python DBAPI module instance.

Member Function Documentation

def MGT::Sql::SqlNumpyTypeMap::dtype (   self,
  descr 
)
Take cursor.description object and return NumPy dtype suitable for record array construction.
dtype is returned in a 'list of tuples' representation e.g. [('id','int8'),('taxid','int4')]
SQL is case insensitive, so we convert field names to lower case when constructing dtype.
@bug 'smallint' in MySQL DBAPI has typecode 2, which is not recognized as NUMBER by that DBAPI.
You should cast 'smallint' fields to some other integer type in your SQL SELECT statement.

The documentation for this class was generated from the following file: