[MonetDB-users] Django Backend: SQL column types
Hi guys, I am jumping straight into the deep end with Monet. My first task is to implement a backend for Django written in Django. I need to map the field types to SQL column types, and that is for the most part easy, yet a few questions: 1) Is 'integer' accepted, or do I have to use 'int' 2) How do I specify a floating point with specified max_digits and decimal_places? I didn't see support for numeric in the docs. 3) How do I specify unsigned integers? unsigned or check expression? Is there a text field, or should I use varchar/clob ? These are my definitions as they stand so far: DATA_TYPES = { 'AutoField': 'serial', 'BooleanField': 'boolean', 'CharField': 'varchar(%(maxlength)s)', 'CommaSeparatedIntegerField': 'varchar(%(maxlength)s)', 'DateField': 'date', 'DateTimeField': 'timestamp', 'FileField': 'varchar(100)', 'FilePathField': 'varchar(100)', 'FloatField': 'numeric(%(max_digits)s, %(decimal_places)s)', 'ImageField': 'varchar(100)', 'IntegerField': 'int', 'IPAddressField': 'char(15)', 'ManyToManyField': None, 'NullBooleanField': 'bool', 'OneToOneField': 'int', 'PhoneNumberField': 'varchar(20)', 'PositiveIntegerField': 'integer unsigned', # TODO how should this be handled??? 'PositiveSmallIntegerField': 'smallint unsigned', # TODO how should this be handled??? 'SlugField': 'varchar(%(maxlength)s)', 'SmallIntegerField': 'smallint', 'TextField': 'text', 'TimeField': 'time', 'USStateField': 'varchar(2)', } Thanks, Henrik
Henrik Vendelbo wrote:
Hi guys,
Hi Hendrik, welcome and we hope you find MonetDB useful for your project.
I am jumping straight into the deep end with Monet. My first task is to implement a backend for Django written in Django.
I need to map the field types to SQL column types, and that is for the most part easy, yet a few questions:
1) Is 'integer' accepted, or do I have to use 'int'
MonetDB follows the SQL standard as close as possible. For the type information see: http://monetdb.cwi.nl/projects/monetdb/SQL/Documentation/Data-Types.html
2) How do I specify a floating point with specified max_digits and decimal_places? I didn't see support for numeric in the docs. 3) How do I specify unsigned integers? unsigned or check expression? Is there a text field, or should I use varchar/clob ?
These are my definitions as they stand so far:
DATA_TYPES = { 'AutoField': 'serial', 'BooleanField': 'boolean', 'CharField': 'varchar(%(maxlength)s)', 'CommaSeparatedIntegerField': 'varchar(%(maxlength)s)', 'DateField': 'date', 'DateTimeField': 'timestamp', 'FileField': 'varchar(100)', 'FilePathField': 'varchar(100)', 'FloatField': 'numeric(%(max_digits)s, %(decimal_places)s)', 'ImageField': 'varchar(100)', 'IntegerField': 'int', 'IPAddressField': 'char(15)', 'ManyToManyField': None, 'NullBooleanField': 'bool', 'OneToOneField': 'int', 'PhoneNumberField': 'varchar(20)', 'PositiveIntegerField': 'integer unsigned', # TODO how should this be handled??? 'PositiveSmallIntegerField': 'smallint unsigned', # TODO how should this be handled??? 'SlugField': 'varchar(%(maxlength)s)', 'SmallIntegerField': 'smallint', 'TextField': 'text', 'TimeField': 'time', 'USStateField': 'varchar(2)', }
Thanks,
Henrik
------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javao... _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
On Sun, May 04, 2008 at 02:33:40PM +0100, Henrik Vendelbo wrote:
Hi guys,
I am jumping straight into the deep end with Monet. My first task is to implement a backend for Django written in Django.
I need to map the field types to SQL column types, and that is for the most part easy, yet a few questions:
1) Is 'integer' accepted, or do I have to use 'int' Yes 'integer' is accepted as well as 'int'. 2) How do I specify a floating point with specified max_digits and decimal_places? I didn't see support for numeric in the docs. Do you mean 'fixed point numerics'. These can be done using your 'FloatField': 'numeric(%(max_digits)s, %(decimal_places)s)', But floating points are given using 'float(max_bits)' where max bits should be <= 53.
3) How do I specify unsigned integers? unsigned or check expression? There is currently no special support for this, ie simply use signed integers. Is there a text field, or should I use varchar/clob ? clob of text (alias for clob).
These are my definitions as they stand so far:
DATA_TYPES = { 'AutoField': 'serial', 'BooleanField': 'boolean', 'CharField': 'varchar(%(maxlength)s)', 'CommaSeparatedIntegerField': 'varchar(%(maxlength)s)', 'DateField': 'date', 'DateTimeField': 'timestamp', 'FileField': 'varchar(100)', 'FilePathField': 'varchar(100)', 'FloatField': 'numeric(%(max_digits)s, %(decimal_places)s)', 'ImageField': 'varchar(100)', 'IntegerField': 'int', 'IPAddressField': 'char(15)',
we also have a module (needs to be loaded first) called inet, see src/sql/inet.sql
'ManyToManyField': None, 'NullBooleanField': 'bool', 'OneToOneField': 'int', 'PhoneNumberField': 'varchar(20)', 'PositiveIntegerField': 'integer unsigned', # TODO how should this be handled??? 'PositiveSmallIntegerField': 'smallint unsigned', # TODO how should this be handled??? 'SlugField': 'varchar(%(maxlength)s)', 'SmallIntegerField': 'smallint', 'TextField': 'text', 'TimeField': 'time', 'USStateField': 'varchar(2)', }
Thanks,
Henrik
Niels
------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javao... _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
-- Niels Nes, Centre for Mathematics and Computer Science (CWI) Kruislaan 413, 1098 SJ Amsterdam, The Netherlands room C0.02, phone ++31 20 592-4098, fax ++31 20 592-4312 url: http://www.cwi.nl/~niels e-mail: Niels.Nes@cwi.nl
participants (3)
-
Henrik Vendelbo
-
Martin Kersten
-
Niels Nes