the thing that worries me about TypePolicy is that its a whole new object and concept to learn just to do something simple, i.e. i want the string "enum" to give me back MSEnumType, or "decimal" to give me back a FloatType or DecimalType.  for that, i still see the plain dictionary of keys->TypeEngines as something simple people could use.

it seems like a TypePolicy, if pursued fully, would probably not even deal with TypeEngine objects....just Python types.  i.e. youd really just say:

Column('mycol', int)
Column('othercol', unicode)

not a bad idea, but also fairly "magical".   one thing about SA is that by default, it wants you to feel "close" to the database....in contrast to most tools that want to make the database invisible.

but. .....maybe an extension that does something like that ?  or just a special TypeEngine for Python types ?  people shouldnt have to learn some new kind of object/concept:

Column('mycol', Integer),    # "normal" column
Column('othercol', Python(str))   # Python 'str' type, figures out whats needed
Column('anothercol', Python(float))   # Python 'float' type, etc.

how about something like that ?  or just we detect python types and automatically create the "Python" type in the background ?  seems much more WYSIWYG than an intermediary object.

im going slow on this one since its a big deal, people arent terribly held back by the lack of features right now, and im in the "Although never is often better than *right* now." space still.

On Jun 22, 2006, at 8:50 PM, Rick Morrison wrote:

Mike, if you've got some time, you may want to review the discussion regarding a TypePolicy scheme a few weeks ago (IIRC the thread was titled something about Decimal/Numeric). If you're digging into type conversion and don't mind a bit more work, this might be a good time to start some work on it.  There's also an open "Blue Sky" ticket on Trac regarding Python type introspection from MetaData that I think fits into this too.

Rick


On 6/22/06, Michael Bayer <[EMAIL PROTECTED]> wrote:
always deal with the trunk, and i would advise you take a look at lib/
sqlalchemy/databases/mysql.py.  the typing system within the module
is quite simple, and should probably have an Enum type (which
probably would subclass MSString), etc.



On Jun 22, 2006, at 7:42 PM, Mike Bernson wrote:

> Would you accept a patch add a more types into the mysql types. I
> would
>  to add a number of them to get a more complete list. Not sure I would
> get all of them.
>
> Is 1654 a version to look at and make the patch for or is there a
> better
> place to start from ?
>
> I would also like to be able to get unsigned arg for math type.
>
> I would also like length on all types. some have default size like
> dates. I would also be willing send this in as part of patch.
>
> I would like to see flag added to the math types for signed/unsigned.
> I am not sure if having new types is a better way of doing things.
>
> Are there any examples of custom types that I can look at.
>
> I have a package that build screens and is trying to get information
> from the database about size and type. Also if enums then also want
> the
> list of values allowed.
>
>
>
> Michael Bayer wrote:
>> MySQL-specific types arent present in the mysql module as of yet.
>> they
>> default to MSString when reflecting and cant be matched.  i
>> committed an
>> extra param "*extra" to the MSString constructor in revision 1654 to
>> consume the extra arguments coming back from those types, so youll
>> get
>> better results.
>>
>> On Jun 22, 2006, at 6:05 PM, Mike Bernson wrote:
>>
>>> I am starting looking into what type of object come back for
>>> different
>>> column types from mysql.
>>>
>>> I am using version 0.2.3 with mysql version 5
>>>
>>> Here is error with a print statement near the problem turned on
>>>
>>> [EMAIL PROTECTED]:~/src/myranch/packages/screen/screen/views 276> python
>>> test1.py
>>> coltype: 'tinyint' args: '(2)'
>>> args! ['2']
>>> coltype: 'tinyint' args: '(2)'
>>> args! ['2']
>>> coltype: 'smallint' args: '(2)'
>>> args! ['2']
>>> coltype: 'smallint' args: '(2)'
>>> args! ['2']
>>> coltype: 'int' args: '(2)'
>>> args! ['2']
>>> coltype: 'int' args: '(2)'
>>> args! ['2']
>>> coltype: 'int' args: '(2)'
>>> args! ['2']
>>> coltype: 'int' args: '(2)'
>>> args! ['2']
>>> coltype: 'bigint' args: '(10)'
>>> args! ['10']
>>> coltype: 'bigint' args: '(10)'
>>> args! ['10']
>>> coltype: 'double' args: '(10,4)'
>>> args! ['10', '4']
>>> coltype: 'double' args: '(10,4)'
>>> args! ['10', '4']
>>> coltype: 'float' args: '(10,4)'
>>> args! ['10', '4']
>>> Traceback (most recent call last):
>>>   File " test1.py", line 9, in ?
>>>     table = Table('testing', metadata, autoload=True)
>>>   File "/home/mike/src/SQLAlchemy-0.2.3/lib/sqlalchemy/
>>> schema.py", line
>>> 96, in __call__
>>>     metadata.engine.reflecttable(table)
>>>   File "/home/mike/src/SQLAlchemy-0.2.3/lib/sqlalchemy/engine/
>>> base.py",
>>> line 484, in reflecttable
>>>     self.dialect.reflecttable(conn, table)
>>>   File
>>> "/home/mike/src/SQLAlchemy-0.2.3/lib/sqlalchemy/databases/mysql.py",
>>> line 207, in reflecttable
>>>     coltype = coltype(*[int(a) for a in args])
>>> TypeError: __init__() takes at most 2 arguments (3 given)
>>>
>>> Here is the python code:
>>> from pkg_resources import require
>>> require('SQLAlchemy')
>>>
>>> from sqlalchemy import *
>>>
>>> engine = create_engine("mysql:///wood_memorial")
>>> metadata = BoundMetaData(engine)
>>> table = Table('testing', metadata, autoload=True)
>>>
>>>
>>> here is the create for the table:
>>>
>>> use wood_memorial
>>>
>>> create table testing (
>>>         type_tiny TINYINT(2) DEFAULT 1,
>>>         type_utiny TINYINT(2) unsigned DEFAULT 2,
>>>         type_small SMALLINT(2) DEFAULT 1,
>>>         type_usmall SMALLINT(2) unsigned DEFAULT 2,
>>>         type_int INT(2) DEFAULT 2,
>>>         type_uint INT(2) unsigned,
>>>         type_integer INTEGER(2) DEFAULT 2,
>>>         type_uinteger INTEGER(2) unsigned,
>>>         type_bigint BIGINT(10),
>>>         type_ubigint BIGINT(10) unsigned,
>>>         type_double DOUBLE(10,4),
>>>         type_udobule DOUBLE(10,4) unsigned,
>>>         type_float FLOAT(10,4),
>>>         type_ufloat FLOAT(10,4) unsigned,
>>>         type_decimal DECIMAL(10,4),
>>>         type_udecimal DECIMAL(10,4) unsigned,
>>>         type_numeric NUMERIC(10,4),
>>>         type_unumeric NUMERIC(10,4) unsigned,
>>>         type_date DATE,
>>>         type_time TIME,
>>>         type_timestape TIMESTAMP,
>>>         type_datetime DATETIME,
>>>         type_year YEAR,
>>>         type_char_ascii CHAR(10) ASCII,
>>>         type_char_unicode CHAR(10) ASCII,
>>>         type_varchar VARCHAR(10),
>>>         type_unum enum('1','2','3')
>>>
>>> )
>>>
>>> Using Tomcat but need to do more? Need to support web services,
>>> security?
>>> Get stuff done quickly with pre-integrated technology to make
>>> your job
>>> easier
>>> Download IBM WebSphere Application Server v.1.0.1 based on Apache
>>> Geronimo
>>> http://sel.as-us.falkag.net/sel ?
>>> cmd=lnk&kid=120709&bid=263057&dat=121642
>>> _______________________________________________
>>> Sqlalchemy-users mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
>>


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
_______________________________________________
Sqlalchemy-users mailing list

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to