[sqlalchemy] Re: Unsigned attributes brake autoload

2010-03-11 Thread MattQc
Here is the create statement of the table causing problem:

--

CREATE TABLE `AdminClass` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `active` tinyint(1) unsigned DEFAULT NULL,
  `en_US` varchar(256) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;

--

Using sqlalchemy version 0.5.8 I don't get this error.

Thanks,
Mathieu

On Mar 10, 6:40 pm, Michael Bayer mike...@zzzcomputing.com wrote:
 MattQc wrote:
  Hi there,
  Using sqlalchemy version 0.6beta1, I am trying to load a mysql table
  which has a field unsigned int.
  Here is the error I got:

 we would have to see your schema since we have working test coverage for
 reflection of INTEGER with unsigned.



    File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
  py2.6.egg/sqlalchemy/schema.py, line 205, in __new__
      table._init(name, metadata, *args, **kw)
    File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
  py2.6.egg/sqlalchemy/schema.py, line 258, in _init
      reflecttable(self, include_columns=include_columns)
    File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
  py2.6.egg/sqlalchemy/engine/base.py, line 1512, in reflecttable
      self.dialect.reflecttable(conn, table, include_columns)
    File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
  py2.6.egg/sqlalchemy/engine/default.py, line 160, in reflecttable
      return insp.reflecttable(table, include_columns)
    File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
  py2.6.egg/sqlalchemy/engine/reflection.py, line 263, in reflecttable
      tbl_opts = self.get_table_options(table_name, schema,
  **table.kwargs)
    File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
  py2.6.egg/sqlalchemy/engine/reflection.py, line 126, in
  get_table_options
      **kw)
    File string, line 1, in lambda
    File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
  py2.6.egg/sqlalchemy/engine/reflection.py, line 40, in cache
      ret = fn(self, con, *args, **kw)
    File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
  py2.6.egg/sqlalchemy/dialects/mysql/base.py, line 1769, in
  get_table_options
      parsed_state = self._parsed_state_or_create(connection,
  table_name, schema, **kw)
    File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
  py2.6.egg/sqlalchemy/dialects/mysql/base.py, line 1868, in
  _parsed_state_or_create
      info_cache=kw.get('info_cache', None)
    File string, line 1, in lambda
    File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
  py2.6.egg/sqlalchemy/engine/reflection.py, line 40, in cache
      ret = fn(self, con, *args, **kw)
    File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
  py2.6.egg/sqlalchemy/dialects/mysql/base.py, line 1899, in
  _setup_parser
      return parser.parse(sql, charset)
    File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
  py2.6.egg/sqlalchemy/dialects/mysql/base.py, line 2044, in parse
      self._parse_column(line, state)
    File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
  py2.6.egg/sqlalchemy/dialects/mysql/base.py, line 2209, in
  _parse_column
      type_instance = col_type(*type_args, **type_kw)
  TypeError: __init__() got an unexpected keyword argument 'unsigned'

  Thanks
  Mathieu

  --
  You received this message because you are subscribed to the Google Groups
  sqlalchemy group.
  To post to this group, send email to sqlalch...@googlegroups.com.
  To unsubscribe from this group, send email to
  sqlalchemy+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/sqlalchemy?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Unsigned attributes brake autoload

2010-03-10 Thread MattQc
Hi there,
Using sqlalchemy version 0.6beta1, I am trying to load a mysql table
which has a field unsigned int.
Here is the error I got:

  File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
py2.6.egg/sqlalchemy/schema.py, line 205, in __new__
table._init(name, metadata, *args, **kw)
  File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
py2.6.egg/sqlalchemy/schema.py, line 258, in _init
reflecttable(self, include_columns=include_columns)
  File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
py2.6.egg/sqlalchemy/engine/base.py, line 1512, in reflecttable
self.dialect.reflecttable(conn, table, include_columns)
  File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
py2.6.egg/sqlalchemy/engine/default.py, line 160, in reflecttable
return insp.reflecttable(table, include_columns)
  File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
py2.6.egg/sqlalchemy/engine/reflection.py, line 263, in reflecttable
tbl_opts = self.get_table_options(table_name, schema,
**table.kwargs)
  File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
py2.6.egg/sqlalchemy/engine/reflection.py, line 126, in
get_table_options
**kw)
  File string, line 1, in lambda
  File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
py2.6.egg/sqlalchemy/engine/reflection.py, line 40, in cache
ret = fn(self, con, *args, **kw)
  File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
py2.6.egg/sqlalchemy/dialects/mysql/base.py, line 1769, in
get_table_options
parsed_state = self._parsed_state_or_create(connection,
table_name, schema, **kw)
  File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
py2.6.egg/sqlalchemy/dialects/mysql/base.py, line 1868, in
_parsed_state_or_create
info_cache=kw.get('info_cache', None)
  File string, line 1, in lambda
  File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
py2.6.egg/sqlalchemy/engine/reflection.py, line 40, in cache
ret = fn(self, con, *args, **kw)
  File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
py2.6.egg/sqlalchemy/dialects/mysql/base.py, line 1899, in
_setup_parser
return parser.parse(sql, charset)
  File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
py2.6.egg/sqlalchemy/dialects/mysql/base.py, line 2044, in parse
self._parse_column(line, state)
  File /usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.6beta1-
py2.6.egg/sqlalchemy/dialects/mysql/base.py, line 2209, in
_parse_column
type_instance = col_type(*type_args, **type_kw)
TypeError: __init__() got an unexpected keyword argument 'unsigned'


Thanks
Mathieu

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Re: Different results with select and object using outerjoin

2008-01-24 Thread MattQc

Thank you for the answer!

Does it have any performance differences between the 3 manners?
Which one could be the fastest if I have a lot of nested joins to do
with other tables?

Thanks

On Jan 23, 4:30 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 On Jan 23, 2008, at 3:28 PM, MattQc wrote:



  Object query returns an empty set:

  In 3: jLane = tblspotbandsol.outerjoin(tbllane,
  tbllane.c.laneid==tblspotbandsol.c.laneid)
  In 4: mapper(LaneClass,jLane)
  Out4: sqlalchemy.orm.mapper.Mapper object at 0xb36f382c
  In 5:
  Session.query(LaneClass).filter(LaneClass.spotbandsolid==32978).all()

 in this case the mapper will attept to compute the natural primary
 key amongst all the columns that are being mapped; by default, it will
 be the primary key columns of tblspotbandsol combined with that of
 tbllane.  If a row does not contain non-null columns for all primary
 key columns, no instance will be returned.  You can see this happening
 if you turn on sqlalchemy.orm.mapper=DEBUG logging.

 The three ways to modify this behavior are to specify
 allow_null_pks=True on the mapper so that a primary key with some
 NULL columns is accepted as a valid primary key, to specify the
 primary_key=[some columns] option to the mapper which indicates
 which columns should be counted as part of the primary key and
 overriding the auto-calculation of such, or to remove the primary key
 columns of tbllane from the columns clause of the selectable which
 you are mapping to which has a similar effect to providing  an
 explicit primary key argument.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Different results with select and object using outerjoin

2008-01-23 Thread MattQc

Hi,
I have different outputs depending on using a select statement as
oppose to an object mapped query. This is happening when I am using
outer joins.

Here is the trace of the select that gives me something:

In 1: a = select([tblspotbandsol.c.spotbandsolid, tbllane.c.laneid],
tblspotbandsol.c.spotbandsolid==32978,
from_obj=[tblspotbandsol.outerjoin(tbllane,
tbllane.c.laneid==tblspotbandsol.c.laneid)])
In 2: Session.execute(a).fetchall()

2008-01-23 15:00:39,034 INFO sqlalchemy.engine.base.Engine.0x..94
SELECT TBLSPOTBANDSOL.spotbandsolid, TBLLANE.laneid
FROM j1.TBLSPOTBANDSOL LEFT OUTER JOIN j1.TBLLANE ON
TBLLANE.laneid = TBLSPOTBANDSOL.laneid
WHERE TBLSPOTBANDSOL.spotbandsolid = :TBLSPOTBANDSOL_spotbandsolid
2008-01-23 15:00:39,035 INFO sqlalchemy.engine.base.Engine.0x..94
{'TBLSPOTBANDSOL_spotbandsolid': 32978.0}
Out2: [(Decimal(32978), None)]


Object query returns an empty set:

In 3: jLane = tblspotbandsol.outerjoin(tbllane,
tbllane.c.laneid==tblspotbandsol.c.laneid)
In 4: mapper(LaneClass,jLane)
Out4: sqlalchemy.orm.mapper.Mapper object at 0xb36f382c
In 5:
Session.query(LaneClass).filter(LaneClass.spotbandsolid==32978).all()

2008-01-23 15:00:59,379 INFO sqlalchemy.engine.base.Engine.0x..94
SELECT TBLSPOTBANDSOL.spotbandsolid AS
TBLSPOTBANDSOL_spotbandsolid, TBLSPOTBANDSOL.class AS
TBLSPOTBANDSOL_class, TBLSPOTBANDSOL.createdate AS
TBLSPOTBANDSOL_createdate, TBLLANE.createdate AS
TBLLANE_createdate, TBLSPOTBANDSOL.createusername AS
TBLSPOTBANDSOL_createusername, TBLLANE.createusername AS
TBLLANE_createusername,  TBLSPOTBANDSOL.laneid AS
TBLSPOTBANDSOL_laneid, TBLLANE.laneid AS TBLLANE_laneid,
TBLSPOTBANDSOL.ltekd AS TBLSPOTBANDSOL_ltekd, TBLLANE.lanenumber
AS TBLLANE_lanenumber, TBLLANE.label AS TBLLANE_label,
FROM j1.TBLSPOTBANDSOL LEFT OUTER JOIN j1.TBLLANE ON
TBLLANE.laneid = TBLSPOTBANDSOL.laneid
WHERE TBLSPOTBANDSOL.spotbandsolid = :TBLSPOTBANDSOL_spotbandsolid
ORDER BY TBLSPOTBANDSOL.rowid
2008-01-23 15:00:59,380 INFO sqlalchemy.engine.base.Engine.0x..94
{'TBLSPOTBANDSOL_spotbandsolid': 32978.0}
Out5: []


I am pretty new with sqlalchemy, so maybe the answer is obvious for
everyone...

Thank you
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] distinct entries when mapping many-to-many

2007-12-05 Thread MattQc

I am mapping 3 tables linearly. The first 2 have a many-to-many
relation and the last one is a one-to-one relation.
I would like to get all the distinct entries from the third table.

I was not able to figure how to do the mapping. So, I tried by doing
my own set of entries outside of SA but when I am trying to retreive
the infos from the third table using in_, my query is too long to be
executed.

How is it possible to do the kind of mapping I would like?

thank you very much,
Mathieu

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---