[sqlalchemy] Re: Weird error using SQLAlchemy 0.7.2, MySQL, Python3, SqlSoup and relate

2011-09-28 Thread Ygor Lemos
I'm keeping a project that does pretty much the same as SQLSoup but
also does automatic relationship and backref mapping.

It also relies on the new Declarative Base and it doesn't rely on
anything from SQLSoup, so when Soup gets discontinued, SQLasagna will
go on :)


You can see the code, fork it and help developing it on:

https://github.com/ygbr/SQLasagna


Thanks.

On Aug 18, 7:44 am, Ygor Lemos opti...@gmail.com wrote:
 If anybody else is experiencing this same problem, I have opened a Bug
 Request @ SQLA Trac and you can follow it through here:

 http://www.sqlalchemy.org/trac/ticket/2260

 On Aug 18, 1:56 am, Ygor Lemos opti...@gmail.com wrote:







  Oh, sorry about that, I copied from a previous declaration I've been
  testing using Table() objects... I did remove the ,'s and all worked
  fine... The relationships are normal both in py3k and py2 with the
  latest SQLA. So the problem really lies on the relate() method of
 SqlSoup.

  Thanks again for your time.

  On Aug 18, 1:25 am, Michael Bayer mike...@zzzcomputing.com wrote:

   On Aug 17, 2011, at 10:15 PM, Ygor Lemos wrote:

I tried the following for manually mapping the tables:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from sqlalchemy import *
from sqlalchemy import dialects
from sqlalchemy import sql
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.sql.expression import *

engine = create_engine(mysql+oursql://:XXX@XX/
XXX?charset=utf8use_unicode=Trueautoping=True, echo=True)
metadata = MetaData(engine)

Base = declarative_base()

class User(Base):

   __tablename__ = users

   id = Column(Integer, primary_key=True),
   login = Column(String(25)),
   name = Column(String(50)),
   passwd = Column(String(100)),
   email = Column(String(100)),
   atype = Column(String(50)),
   active = Column(Boolean),
   customers_id = Column('customers_id', Integer,
ForeignKey('customers.id')),

   all of those commas at the end of each line results in the class having a 
   tuple called id in it, rather than a set of attributes id, login, 
   name etc which declarative can interpret as mapping directives.

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Re: Weird error using SQLAlchemy 0.7.2, MySQL, Python3, SqlSoup and relate

2011-08-18 Thread Ygor Lemos
If anybody else is experience the same problem, I have opened a Bug
Request @ SQLA Trac, you can follow it through here:

http://www.sqlalchemy.org/trac/ticket/2260


On Aug 18, 1:56 am, Ygor Lemos opti...@gmail.com wrote:
 Oh, sorry about that, I copied from a previous declaration I've been
 testing using Table() objects... I did remove the ,'s and all worked
 fine... The relationships are normal both in py3k and py2 with the
 latest SQLA. So the problem really lies on the relate() method of
 SqlSoup.

 Thanks again for your time.

 On Aug 18, 1:25 am, Michael Bayer mike...@zzzcomputing.com wrote:







  On Aug 17, 2011, at 10:15 PM, Ygor Lemos wrote:

   I tried the following for manually mapping the tables:

   #!/usr/bin/env python3
   # -*- coding: utf-8 -*-

   from sqlalchemy import *
   from sqlalchemy import dialects
   from sqlalchemy import sql
   from sqlalchemy.orm import *
   from sqlalchemy.ext.declarative import declarative_base
   from sqlalchemy.sql.expression import *

   engine = create_engine(mysql+oursql://:XXX@XX/
   XXX?charset=utf8use_unicode=Trueautoping=True, echo=True)
   metadata = MetaData(engine)

   Base = declarative_base()

   class User(Base):

      __tablename__ = users

      id = Column(Integer, primary_key=True),
      login = Column(String(25)),
      name = Column(String(50)),
      passwd = Column(String(100)),
      email = Column(String(100)),
      atype = Column(String(50)),
      active = Column(Boolean),
      customers_id = Column('customers_id', Integer,
   ForeignKey('customers.id')),

  all of those commas at the end of each line results in the class having a 
  tuple called id in it, rather than a set of attributes id, login, 
  name etc which declarative can interpret as mapping directives.

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Re: Weird error using SQLAlchemy 0.7.2, MySQL, Python3, SqlSoup and relate

2011-08-18 Thread Ygor Lemos
If anybody else is experiencing this same problem, I have opened a Bug
Request @ SQLA Trac and you can follow it through here:


http://www.sqlalchemy.org/trac/ticket/2260


On Aug 18, 1:56 am, Ygor Lemos opti...@gmail.com wrote:
 Oh, sorry about that, I copied from a previous declaration I've been
 testing using Table() objects... I did remove the ,'s and all worked
 fine... The relationships are normal both in py3k and py2 with the
 latest SQLA. So the problem really lies on the relate() method of
 SqlSoup.

 Thanks again for your time.

 On Aug 18, 1:25 am, Michael Bayer mike...@zzzcomputing.com wrote:







  On Aug 17, 2011, at 10:15 PM, Ygor Lemos wrote:

   I tried the following for manually mapping the tables:

   #!/usr/bin/env python3
   # -*- coding: utf-8 -*-

   from sqlalchemy import *
   from sqlalchemy import dialects
   from sqlalchemy import sql
   from sqlalchemy.orm import *
   from sqlalchemy.ext.declarative import declarative_base
   from sqlalchemy.sql.expression import *

   engine = create_engine(mysql+oursql://:XXX@XX/
   XXX?charset=utf8use_unicode=Trueautoping=True, echo=True)
   metadata = MetaData(engine)

   Base = declarative_base()

   class User(Base):

      __tablename__ = users

      id = Column(Integer, primary_key=True),
      login = Column(String(25)),
      name = Column(String(50)),
      passwd = Column(String(100)),
      email = Column(String(100)),
      atype = Column(String(50)),
      active = Column(Boolean),
      customers_id = Column('customers_id', Integer,
   ForeignKey('customers.id')),

  all of those commas at the end of each line results in the class having a 
  tuple called id in it, rather than a set of attributes id, login, 
  name etc which declarative can interpret as mapping directives.

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Weird error using SQLAlchemy 0.7.2, MySQL, Python3, SqlSoup and relate

2011-08-17 Thread Ygor Lemos
Hi,

I was trying to do a simple relate according to SqlSoup documentation,
but this error keeps popping every time for every tables I try to
relate even though the foreign keys are right and valid and a manual
SQL join works normally:




 db.audits.relate('customer', db.customers)
2011-08-17 16:46:22,560 INFO sqlalchemy.engine.base.Engine SELECT
DATABASE()
2011-08-17 16:46:22,561 INFO sqlalchemy.engine.base.Engine ()
2011-08-17 16:46:22,564 INFO sqlalchemy.engine.base.Engine SHOW
VARIABLES LIKE 'lower_case_table_names'
2011-08-17 16:46:22,564 INFO sqlalchemy.engine.base.Engine ()
2011-08-17 16:46:22,565 INFO sqlalchemy.engine.base.Engine SHOW
COLLATION
2011-08-17 16:46:22,565 INFO sqlalchemy.engine.base.Engine ()
2011-08-17 16:46:22,571 INFO sqlalchemy.engine.base.Engine SHOW
VARIABLES LIKE 'sql_mode'
2011-08-17 16:46:22,571 INFO sqlalchemy.engine.base.Engine ()
2011-08-17 16:46:22,592 INFO sqlalchemy.engine.base.Engine SHOW CREATE
TABLE `audits`
2011-08-17 16:46:22,592 INFO sqlalchemy.engine.base.Engine ()
2011-08-17 16:46:22,595 INFO sqlalchemy.engine.base.Engine SHOW CREATE
TABLE `customers`
2011-08-17 16:46:22,595 INFO sqlalchemy.engine.base.Engine ()
2011-08-17 16:46:22,597 INFO sqlalchemy.engine.base.Engine SHOW CREATE
TABLE `users`
2011-08-17 16:46:22,597 INFO sqlalchemy.engine.base.Engine ()
 a = db.audits.first()
2011-08-17 16:46:39,724 INFO sqlalchemy.engine.base.Engine BEGIN
(implicit)
2011-08-17 16:46:39,725 INFO sqlalchemy.engine.base.Engine SELECT
audits.id AS audits_id, audits.site AS audits_site, audits.zeit AS
audits_zeit, audits.responsible AS audits_responsible, audits.prologue
AS audits_prologue, audits.checklists AS audits_checklists,
audits.utype AS audits_utype, audits.customers_id AS
audits_customers_id, audits.users_id AS audits_users_id
FROM audits
 LIMIT ?, ?
2011-08-17 16:46:39,725 INFO sqlalchemy.engine.base.Engine (0, 1)


 a
MappedAudits(id=179,site='123',zeit=datetime.datetime(2011, 8, 15, 3,
20,
38),responsible='123',prologue='123',checklists='4',utype=None,customers_id=1,users_id=3)


 a.customer
2011-08-17 16:46:48,668 INFO sqlalchemy.engine.base.Engine SELECT
customers.id AS customers_id, customers.name AS customers_name,
customers.doc AS customers_doc, customers.email AS customers_email,
customers.active AS customers_active
FROM customers
WHERE customers.id = ?
2011-08-17 16:46:48,668 INFO sqlalchemy.engine.base.Engine (1,)

Traceback (most recent call last):
  File /usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
py3.2.egg/sqlalchemy/ext/sqlsoup.py, line 474, in _compare
t2 = [getattr(o, k) for k in L]
  File /usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
py3.2.egg/sqlalchemy/ext/sqlsoup.py, line 474, in listcomp
t2 = [getattr(o, k) for k in L]
AttributeError: 'symbol' object has no attribute 'active'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
py3.2.egg/sqlalchemy/orm/attributes.py, line 168, in __get__
return self.impl.get(instance_state(instance),dict_)
  File /usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
py3.2.egg/sqlalchemy/orm/attributes.py, line 424, in get
if value in (PASSIVE_NO_RESULT, NEVER_SET):
  File /usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
py3.2.egg/sqlalchemy/ext/sqlsoup.py, line 487, in __eq__
t1, t2 = _compare(self, o)
  File /usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
py3.2.egg/sqlalchemy/ext/sqlsoup.py, line 476, in _compare
raise TypeError('unable to compare with %s' % o.__class__)
TypeError: unable to compare with class
'sqlalchemy.util.langhelpers.symbol'




My Foreign keys are all correctly setup and as a simple relation this
should just work, but I have no idea on what is going on with this.
Anybody had the same issue ?


Follows a description of my environment and the related tables:

OS: Tested on both Linux Ubuntu Natty 64bit and Mac OS X 10.7.1 Lion.
Python: Python 3.2.1
SQLAlchemy: 0.7.2
MySQL: 5.5.12
MySQL Python Driver/Connector: OurSQL 0.9.2


Follows the tables description:


=== audits ===

CREATE TABLE `audits` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `site` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
  `zeit` datetime NOT NULL COMMENT 'date the audit was started (zeit =
german for time)',
  `responsible` varchar(100) CHARACTER SET latin1 NOT NULL,
  `prologue` text CHARACTER SET latin1 COMMENT 'digest at the
beginning',
  `checklists` varchar(30) DEFAULT ' ',
  `utype` varchar(45) DEFAULT NULL,
  `customers_id` int(10) unsigned NOT NULL,
  `users_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_audits_users1` (`users_id`),
  KEY `utype` (`utype`) USING BTREE,
  KEY `fk_audits_customers1` (`customers_id`),
  CONSTRAINT `fk_audits_customers1` FOREIGN KEY (`customers_id`)
REFERENCES `customers` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT 

[sqlalchemy] Re: Weird error using SQLAlchemy 0.7.2, MySQL, Python3, SqlSoup and relate

2011-08-17 Thread Ygor Lemos
I've got the same error on Python 2.7 under Mac OS X 10.7.1 running
with oursql 0.9.2 for Python 2.x.

But I really need Python 3 for this project as I have developed a web
framework (soon to be published on GitHub as Serendipity) that is
intrinsically linked against Python 3. This framework uses SQLAlchemy
SqlSoup as the alternative for connecting to relational databases as
it also have pluggable models for NoSQL DB's like MongoDB, CouchDB,
etc...

The ultimate goal is to provide automatic mapping on relational
databases for rapid application development.

Actually everything but relations is working fine.

I have not tested yet with manual mappings.

Are there any plans for SqlSoup continuation?

On Aug 17, 5:39 pm, Michael Bayer mike...@zzzcomputing.com wrote:
 We don't have very good support for SqlSoup as it was written many years ago 
 and is only updated occasionally, can you reproduce your error using normal 
 SQLAlchemy mappings + table reflection ?   Or at least trying Python 2 ?

 On Aug 17, 2011, at 3:53 PM, Ygor Lemos wrote:







  Hi,

  I was trying to do a simple relate according to SqlSoup documentation,
  but this error keeps popping every time for every tables I try to
  relate even though the foreign keys are right and valid and a manual
  SQL join works normally:

  db.audits.relate('customer', db.customers)
  2011-08-17 16:46:22,560 INFO sqlalchemy.engine.base.Engine SELECT
  DATABASE()
  2011-08-17 16:46:22,561 INFO sqlalchemy.engine.base.Engine ()
  2011-08-17 16:46:22,564 INFO sqlalchemy.engine.base.Engine SHOW
  VARIABLES LIKE 'lower_case_table_names'
  2011-08-17 16:46:22,564 INFO sqlalchemy.engine.base.Engine ()
  2011-08-17 16:46:22,565 INFO sqlalchemy.engine.base.Engine SHOW
  COLLATION
  2011-08-17 16:46:22,565 INFO sqlalchemy.engine.base.Engine ()
  2011-08-17 16:46:22,571 INFO sqlalchemy.engine.base.Engine SHOW
  VARIABLES LIKE 'sql_mode'
  2011-08-17 16:46:22,571 INFO sqlalchemy.engine.base.Engine ()
  2011-08-17 16:46:22,592 INFO sqlalchemy.engine.base.Engine SHOW CREATE
  TABLE `audits`
  2011-08-17 16:46:22,592 INFO sqlalchemy.engine.base.Engine ()
  2011-08-17 16:46:22,595 INFO sqlalchemy.engine.base.Engine SHOW CREATE
  TABLE `customers`
  2011-08-17 16:46:22,595 INFO sqlalchemy.engine.base.Engine ()
  2011-08-17 16:46:22,597 INFO sqlalchemy.engine.base.Engine SHOW CREATE
  TABLE `users`
  2011-08-17 16:46:22,597 INFO sqlalchemy.engine.base.Engine ()
  a = db.audits.first()
  2011-08-17 16:46:39,724 INFO sqlalchemy.engine.base.Engine BEGIN
  (implicit)
  2011-08-17 16:46:39,725 INFO sqlalchemy.engine.base.Engine SELECT
  audits.id AS audits_id, audits.site AS audits_site, audits.zeit AS
  audits_zeit, audits.responsible AS audits_responsible, audits.prologue
  AS audits_prologue, audits.checklists AS audits_checklists,
  audits.utype AS audits_utype, audits.customers_id AS
  audits_customers_id, audits.users_id AS audits_users_id
  FROM audits
  LIMIT ?, ?
  2011-08-17 16:46:39,725 INFO sqlalchemy.engine.base.Engine (0, 1)

  a
  MappedAudits(id=179,site='123',zeit=datetime.datetime(2011, 8, 15, 3,
  20,
  38),responsible='123',prologue='123',checklists='4',utype=None,customers_id 
  =1,users_id=3)

  a.customer
  2011-08-17 16:46:48,668 INFO sqlalchemy.engine.base.Engine SELECT
  customers.id AS customers_id, customers.name AS customers_name,
  customers.doc AS customers_doc, customers.email AS customers_email,
  customers.active AS customers_active
  FROM customers
  WHERE customers.id = ?
  2011-08-17 16:46:48,668 INFO sqlalchemy.engine.base.Engine (1,)

  Traceback (most recent call last):
   File /usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
  py3.2.egg/sqlalchemy/ext/sqlsoup.py, line 474, in _compare
     t2 = [getattr(o, k) for k in L]
   File /usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
  py3.2.egg/sqlalchemy/ext/sqlsoup.py, line 474, in listcomp
     t2 = [getattr(o, k) for k in L]
  AttributeError: 'symbol' object has no attribute 'active'

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
   File stdin, line 1, in module
   File /usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
  py3.2.egg/sqlalchemy/orm/attributes.py, line 168, in __get__
     return self.impl.get(instance_state(instance),dict_)
   File /usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
  py3.2.egg/sqlalchemy/orm/attributes.py, line 424, in get
     if value in (PASSIVE_NO_RESULT, NEVER_SET):
   File /usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
  py3.2.egg/sqlalchemy/ext/sqlsoup.py, line 487, in __eq__
     t1, t2 = _compare(self, o)
   File /usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
  py3.2.egg/sqlalchemy/ext/sqlsoup.py, line 476, in _compare
     raise TypeError('unable to compare with %s' % o.__class__)
  TypeError: unable to compare with class
  'sqlalchemy.util.langhelpers.symbol'

  My Foreign keys are all correctly setup and as a simple relation this
  should

[sqlalchemy] Re: Weird error using SQLAlchemy 0.7.2, MySQL, Python3, SqlSoup and relate

2011-08-17 Thread Ygor Lemos
Seems fine to me :) I'll be happy to help on SQLSoup future.

Please let me know if anyone on the list responds on behalf of this
bug. I can help with further data if needed.

Thanks Michael !

On Aug 17, 7:20 pm, Michael Bayer mike...@zzzcomputing.com wrote:
 On Aug 17, 2011, at 5:19 PM, Ygor Lemos wrote:









  I've got the same error on Python 2.7 under Mac OS X 10.7.1 running
  with oursql 0.9.2 for Python 2.x.

  But I really need Python 3 for this project as I have developed a web
  framework (soon to be published on GitHub as Serendipity) that is
  intrinsically linked against Python 3. This framework uses SQLAlchemy
  SqlSoup as the alternative for connecting to relational databases as
  it also have pluggable models for NoSQL DB's like MongoDB, CouchDB,
  etc...

  The ultimate goal is to provide automatic mapping on relational
  databases for rapid application development.

  Actually everything but relations is working fine.

  I have not tested yet with manual mappings.

  Are there any plans for SqlSoup continuation?

 It's likely this is some simple bug in SqlSoup.    I've never seen this error 
 in particular which leads me to believe the relate() command of SqlSoup is 
 probably not that widely used.   I've asked on the development list if anyone 
 is willing to debug into simple issues like these.

 The vast majority of SQLA users are on Declarative so if you'd like to 
 standardize on SqlSoup, that's great, but you might need to help out with 
 maintenance if you want your users to stay happy with it.    It's a very 
 simple module.









  On Aug 17, 5:39 pm, Michael Bayer mike...@zzzcomputing.com wrote:
  We don't have very good support for SqlSoup as it was written many years 
  ago and is only updated occasionally, can you reproduce your error using 
  normal SQLAlchemy mappings + table reflection ?   Or at least trying 
  Python 2 ?

  On Aug 17, 2011, at 3:53 PM, Ygor Lemos wrote:

  Hi,

  I was trying to do a simple relate according to SqlSoup documentation,
  but this error keeps popping every time for every tables I try to
  relate even though the foreign keys are right and valid and a manual
  SQL join works normally:

  db.audits.relate('customer', db.customers)
  2011-08-17 16:46:22,560 INFO sqlalchemy.engine.base.Engine SELECT
  DATABASE()
  2011-08-17 16:46:22,561 INFO sqlalchemy.engine.base.Engine ()
  2011-08-17 16:46:22,564 INFO sqlalchemy.engine.base.Engine SHOW
  VARIABLES LIKE 'lower_case_table_names'
  2011-08-17 16:46:22,564 INFO sqlalchemy.engine.base.Engine ()
  2011-08-17 16:46:22,565 INFO sqlalchemy.engine.base.Engine SHOW
  COLLATION
  2011-08-17 16:46:22,565 INFO sqlalchemy.engine.base.Engine ()
  2011-08-17 16:46:22,571 INFO sqlalchemy.engine.base.Engine SHOW
  VARIABLES LIKE 'sql_mode'
  2011-08-17 16:46:22,571 INFO sqlalchemy.engine.base.Engine ()
  2011-08-17 16:46:22,592 INFO sqlalchemy.engine.base.Engine SHOW CREATE
  TABLE `audits`
  2011-08-17 16:46:22,592 INFO sqlalchemy.engine.base.Engine ()
  2011-08-17 16:46:22,595 INFO sqlalchemy.engine.base.Engine SHOW CREATE
  TABLE `customers`
  2011-08-17 16:46:22,595 INFO sqlalchemy.engine.base.Engine ()
  2011-08-17 16:46:22,597 INFO sqlalchemy.engine.base.Engine SHOW CREATE
  TABLE `users`
  2011-08-17 16:46:22,597 INFO sqlalchemy.engine.base.Engine ()
  a = db.audits.first()
  2011-08-17 16:46:39,724 INFO sqlalchemy.engine.base.Engine BEGIN
  (implicit)
  2011-08-17 16:46:39,725 INFO sqlalchemy.engine.base.Engine SELECT
  audits.id AS audits_id, audits.site AS audits_site, audits.zeit AS
  audits_zeit, audits.responsible AS audits_responsible, audits.prologue
  AS audits_prologue, audits.checklists AS audits_checklists,
  audits.utype AS audits_utype, audits.customers_id AS
  audits_customers_id, audits.users_id AS audits_users_id
  FROM audits
  LIMIT ?, ?
  2011-08-17 16:46:39,725 INFO sqlalchemy.engine.base.Engine (0, 1)

  a
  MappedAudits(id=179,site='123',zeit=datetime.datetime(2011, 8, 15, 3,
  20,
  38),responsible='123',prologue='123',checklists='4',utype=None,customers_id
   =1,users_id=3)

  a.customer
  2011-08-17 16:46:48,668 INFO sqlalchemy.engine.base.Engine SELECT
  customers.id AS customers_id, customers.name AS customers_name,
  customers.doc AS customers_doc, customers.email AS customers_email,
  customers.active AS customers_active
  FROM customers
  WHERE customers.id = ?
  2011-08-17 16:46:48,668 INFO sqlalchemy.engine.base.Engine (1,)

  Traceback (most recent call last):
   File /usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
  py3.2.egg/sqlalchemy/ext/sqlsoup.py, line 474, in _compare
     t2 = [getattr(o, k) for k in L]
   File /usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
  py3.2.egg/sqlalchemy/ext/sqlsoup.py, line 474, in listcomp
     t2 = [getattr(o, k) for k in L]
  AttributeError: 'symbol' object has no attribute 'active'

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
   File stdin

[sqlalchemy] Re: Weird error using SQLAlchemy 0.7.2, MySQL, Python3, SqlSoup and relate

2011-08-17 Thread Ygor Lemos
))
sqlalchemy.exc.ArgumentError: Mapper Mapper|User|users could not
assemble any primary key columns for mapped table 'users'




Any ideas?

Thanks!



On Aug 17, 7:25 pm, Ygor Lemos opti...@gmail.com wrote:
 Seems fine to me :) I'll be happy to help on SQLSoup future.

 Please let me know if anyone on the list responds on behalf of this
 bug. I can help with further data if needed.

 Thanks Michael !

 On Aug 17, 7:20 pm, Michael Bayer mike...@zzzcomputing.com wrote:







  On Aug 17, 2011, at 5:19 PM, Ygor Lemos wrote:

   I've got the same error on Python 2.7 under Mac OS X 10.7.1 running
   with oursql 0.9.2 for Python 2.x.

   But I really need Python 3 for this project as I have developed a web
   framework (soon to be published on GitHub as Serendipity) that is
   intrinsically linked against Python 3. This framework uses SQLAlchemy
   SqlSoup as the alternative for connecting to relational databases as
   it also have pluggable models for NoSQL DB's like MongoDB, CouchDB,
   etc...

   The ultimate goal is to provide automatic mapping on relational
   databases for rapid application development.

   Actually everything but relations is working fine.

   I have not tested yet with manual mappings.

   Are there any plans for SqlSoup continuation?

  It's likely this is some simple bug in SqlSoup.    I've never seen this 
  error in particular which leads me to believe the relate() command of 
  SqlSoup is probably not that widely used.   I've asked on the development 
  list if anyone is willing to debug into simple issues like these.

  The vast majority of SQLA users are on Declarative so if you'd like to 
  standardize on SqlSoup, that's great, but you might need to help out with 
  maintenance if you want your users to stay happy with it.    It's a very 
  simple module.

   On Aug 17, 5:39 pm, Michael Bayer mike...@zzzcomputing.com wrote:
   We don't have very good support for SqlSoup as it was written many years 
   ago and is only updated occasionally, can you reproduce your error using 
   normal SQLAlchemy mappings + table reflection ?   Or at least trying 
   Python 2 ?

   On Aug 17, 2011, at 3:53 PM, Ygor Lemos wrote:

   Hi,

   I was trying to do a simple relate according to SqlSoup documentation,
   but this error keeps popping every time for every tables I try to
   relate even though the foreign keys are right and valid and a manual
   SQL join works normally:

   db.audits.relate('customer', db.customers)
   2011-08-17 16:46:22,560 INFO sqlalchemy.engine.base.Engine SELECT
   DATABASE()
   2011-08-17 16:46:22,561 INFO sqlalchemy.engine.base.Engine ()
   2011-08-17 16:46:22,564 INFO sqlalchemy.engine.base.Engine SHOW
   VARIABLES LIKE 'lower_case_table_names'
   2011-08-17 16:46:22,564 INFO sqlalchemy.engine.base.Engine ()
   2011-08-17 16:46:22,565 INFO sqlalchemy.engine.base.Engine SHOW
   COLLATION
   2011-08-17 16:46:22,565 INFO sqlalchemy.engine.base.Engine ()
   2011-08-17 16:46:22,571 INFO sqlalchemy.engine.base.Engine SHOW
   VARIABLES LIKE 'sql_mode'
   2011-08-17 16:46:22,571 INFO sqlalchemy.engine.base.Engine ()
   2011-08-17 16:46:22,592 INFO sqlalchemy.engine.base.Engine SHOW CREATE
   TABLE `audits`
   2011-08-17 16:46:22,592 INFO sqlalchemy.engine.base.Engine ()
   2011-08-17 16:46:22,595 INFO sqlalchemy.engine.base.Engine SHOW CREATE
   TABLE `customers`
   2011-08-17 16:46:22,595 INFO sqlalchemy.engine.base.Engine ()
   2011-08-17 16:46:22,597 INFO sqlalchemy.engine.base.Engine SHOW CREATE
   TABLE `users`
   2011-08-17 16:46:22,597 INFO sqlalchemy.engine.base.Engine ()
   a = db.audits.first()
   2011-08-17 16:46:39,724 INFO sqlalchemy.engine.base.Engine BEGIN
   (implicit)
   2011-08-17 16:46:39,725 INFO sqlalchemy.engine.base.Engine SELECT
   audits.id AS audits_id, audits.site AS audits_site, audits.zeit AS
   audits_zeit, audits.responsible AS audits_responsible, audits.prologue
   AS audits_prologue, audits.checklists AS audits_checklists,
   audits.utype AS audits_utype, audits.customers_id AS
   audits_customers_id, audits.users_id AS audits_users_id
   FROM audits
   LIMIT ?, ?
   2011-08-17 16:46:39,725 INFO sqlalchemy.engine.base.Engine (0, 1)

   a
   MappedAudits(id=179,site='123',zeit=datetime.datetime(2011, 8, 15, 3,
   20,
   38),responsible='123',prologue='123',checklists='4',utype=None,customers_id
=1,users_id=3)

   a.customer
   2011-08-17 16:46:48,668 INFO sqlalchemy.engine.base.Engine SELECT
   customers.id AS customers_id, customers.name AS customers_name,
   customers.doc AS customers_doc, customers.email AS customers_email,
   customers.active AS customers_active
   FROM customers
   WHERE customers.id = ?
   2011-08-17 16:46:48,668 INFO sqlalchemy.engine.base.Engine (1,)

   Traceback (most recent call last):
    File /usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
   py3.2.egg/sqlalchemy/ext/sqlsoup.py, line 474, in _compare
      t2 = [getattr(o, k) for k in L]
    File /usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.7.2-
   py3.2.egg

[sqlalchemy] Re: Weird error using SQLAlchemy 0.7.2, MySQL, Python3, SqlSoup and relate

2011-08-17 Thread Ygor Lemos
Oh, sorry about that, I copied from a previous declaration I've been
testing using Table() objects... I did remove the ,'s and all worked
fine... The relationships are normal both in py3k and py2 with the
latest SQLA. So the problem really lies on the relate() method of
SqlSoup.


Thanks again for your time.

On Aug 18, 1:25 am, Michael Bayer mike...@zzzcomputing.com wrote:
 On Aug 17, 2011, at 10:15 PM, Ygor Lemos wrote:









  I tried the following for manually mapping the tables:

  #!/usr/bin/env python3
  # -*- coding: utf-8 -*-

  from sqlalchemy import *
  from sqlalchemy import dialects
  from sqlalchemy import sql
  from sqlalchemy.orm import *
  from sqlalchemy.ext.declarative import declarative_base
  from sqlalchemy.sql.expression import *

  engine = create_engine(mysql+oursql://:XXX@XX/
  XXX?charset=utf8use_unicode=Trueautoping=True, echo=True)
  metadata = MetaData(engine)

  Base = declarative_base()

  class User(Base):

     __tablename__ = users

     id = Column(Integer, primary_key=True),
     login = Column(String(25)),
     name = Column(String(50)),
     passwd = Column(String(100)),
     email = Column(String(100)),
     atype = Column(String(50)),
     active = Column(Boolean),
     customers_id = Column('customers_id', Integer,
  ForeignKey('customers.id')),

 all of those commas at the end of each line results in the class having a 
 tuple called id in it, rather than a set of attributes id, login, 
 name etc which declarative can interpret as mapping directives.

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.