[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] 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 

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

2011-08-17 Thread Michael Bayer

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, 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 

[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
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')),
lastlogin = Column('last_login', DateTime)

customer = relationship(Customer)

def __init__(self, login, name, passwd):
self.login = login
self.name = name
self.passwd = passwd

def __repr__(self):
return User('%s','%s,'%s') % (self.login, self.name,
self.passwd)

class Customer(Base):

__tablename__ = 'customers'

id = Column(Integer, primary_key=True),
name = Column(String(100)),
doc = Column(String(25)),
email = Column(String(100)),
active = Column(Boolean)


Session = sessionmaker(bind=engine)
session = Session()



But I'm getting the following error:


/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-
packages/sqlalchemy/ext/declarative.py:1165: SAWarning: Ignoring
declarative-like tuple value of attribute name: possibly a copy-and-
paste error with a comma left at the end of the line?
  _as_declarative(cls, classname, cls.__dict__)
/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-
packages/sqlalchemy/ext/declarative.py:1165: SAWarning: Ignoring
declarative-like tuple value of attribute passwd: possibly a copy-and-
paste error with a comma left at the end of the line?
  _as_declarative(cls, classname, cls.__dict__)
/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-
packages/sqlalchemy/ext/declarative.py:1165: SAWarning: Ignoring
declarative-like tuple value of attribute atype: possibly a copy-and-
paste error with a comma left at the end of the line?
  _as_declarative(cls, classname, cls.__dict__)
/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-
packages/sqlalchemy/ext/declarative.py:1165: SAWarning: Ignoring
declarative-like tuple value of attribute id: possibly a copy-and-
paste error with a comma left at the end of the line?
  _as_declarative(cls, classname, cls.__dict__)
/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-
packages/sqlalchemy/ext/declarative.py:1165: SAWarning: Ignoring
declarative-like tuple value of attribute customers_id: possibly a
copy-and-paste error with a comma left at the end of the line?
  _as_declarative(cls, classname, cls.__dict__)
/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-
packages/sqlalchemy/ext/declarative.py:1165: SAWarning: Ignoring
declarative-like tuple value of attribute email: possibly a copy-and-
paste error with a comma left at the end of the line?
  _as_declarative(cls, classname, cls.__dict__)
/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-
packages/sqlalchemy/ext/declarative.py:1165: SAWarning: Ignoring
declarative-like tuple value of attribute login: possibly a copy-and-
paste error with a comma left at the end of the line?
  _as_declarative(cls, classname, cls.__dict__)
/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-
packages/sqlalchemy/ext/declarative.py:1165: SAWarning: Ignoring
declarative-like tuple value of attribute active: possibly a copy-and-
paste error with a comma left at the end of the line?
  _as_declarative(cls, classname, cls.__dict__)
Traceback (most recent call last):
  File /Users/yg/Developer/sandbox/samanual/sa.py, line 59, in
module
class User(Base):
  File /Library/Frameworks/Python.framework/Versions/3.2/lib/
python3.2/site-packages/sqlalchemy/ext/declarative.py, line 1165, in
__init__
_as_declarative(cls, classname, cls.__dict__)
  File /Library/Frameworks/Python.framework/Versions/3.2/lib/
python3.2/site-packages/sqlalchemy/ext/declarative.py, line 1158, in
_as_declarative
**mapper_args)
  File /Library/Frameworks/Python.framework/Versions/3.2/lib/
python3.2/site-packages/sqlalchemy/orm/__init__.py, line 889, in
mapper
return Mapper(class_, local_table, *args, **params)
  File /Library/Frameworks/Python.framework/Versions/3.2/lib/
python3.2/site-packages/sqlalchemy/orm/mapper.py, line 214, in
__init__
self._configure_pks()
  File /Library/Frameworks/Python.framework/Versions/3.2/lib/
python3.2/site-packages/sqlalchemy/orm/mapper.py, line 733, in
_configure_pks
(self, self.mapped_table.description))

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

2011-08-17 Thread Michael Bayer

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-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.