- marked as major
- assigned issue to
- changed component to documentation
SQLAlchemy never seems to work correctly in IDLE
Cannot map tables to classes. The following is the error that results from following the example in the SQLAlchemy 0.4.0 documentation found at the following URL: http://www.sqlalchemy.org/docs/04/ormtutorial.html
----- Output:
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) v.1310 32 bit (Intel) on win32 Type "copyright", "credits" or "license()" for more information.
****************************************************************
Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface. This connection is not visible on any external
interface and no data is sent to or received from the Internet.
****************************************************************
IDLE 1.2.1 ==== No Subprocess ====
import sqlalchemy sqlalchemy.version '0.4.0beta5' from sqlalchemy import create_engine engine = create_engine('sqlite:///:memory:', echo=True) from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey metadata = MetaData() users_table = Table('users', metadata,Column('id', Integer, primary_key=True),Column('name', String(40)),Column('fullname', String(100)),Column('password', String(15))) metadata.create_all(engine) class User(object): def init(self, name, fullname, password): self.name = name self.fullname = fullname self.password = password
def __repr__(self):
return "<User(%r,%r, %r)>" % (self.name, self.fullname, self.password)
from sqlalchemy.orm import mapper mapper(User, users_table) <sqlalchemy.orm.mapper.Mapper object at 0x037A7A70> ed_user = User('ed', 'Ed Jones', 'edspassword')
Traceback (most recent call last):
File "<pyshell#15>", line 1, in <module>
ed_user = User('ed', 'Ed Jones', 'edspassword')
File "C:\program files\Python25\lib\site-packages\sqlalchemy\orm\mapper.py", line 677, in init
self.compile()
File "C:\program files\Python25\lib\site-packages\sqlalchemy\orm\mapper.py", line 220, in compile
self.compile_all()
File "C:\program files\Python25\lib\site-packages\sqlalchemy\orm\mapper.py", line 235, in _compile_all
mapper._do_compile()
File "C:\program files\Python25\lib\site-packages\sqlalchemy\orm\mapper.py", line 257, in _do_compile
self.__log("_do_compile() started")
File "C:\program files\Python25\lib\site-packages\sqlalchemy\orm\mapper.py", line 157, in __log
self.logger.info("(" + self.class.name + "|" + (self.entity_name is not None and "/%s" % self.entity_name or "") + (self.local_table and self.local_table.name or str(self.local_table)) + (not self._is_primary_mapper() and "|non-primary" or "") + ") " + msg)
AttributeError: 'str' object has no attribute 'name'
Comments (6)
-
-
Account Deleted Strange - it works if I run a script containing the code from the documentation example from a Windows command line. However, if I try to run the same script from an IDLE python shell, I get the AttributeError?: 'str' object has no attribute 'name' error. Any ideas why this is happening?
-
repo owner - marked as minor
- changed milestone to blue sky
- changed component to tests
- changed title to SQLAlchemy never seems to work correctly in IDLE
sqlalchemy behaves very weirdly in IDLE, for currently unknown reasons. Seems like idle has too much magic and we have too much....alchemy ;)
someone will have to sit down and figure out just whats going on in that regard. Its not unheard of that SA has some slightly weird getattr or import behavior that throws off some of these tools (like pydoc wasnt working with the sql.py/expressions.py module until recently, for example, due to a single getattr method).
-
FWIW this one works fine for me in 2.5.1 IDLE on macosx.
-
Account Deleted This code works for me in IDLE on Windows
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) v.1310 32 bit (Intel) on win32[BR] IDLE 1.2[BR] SQLAlchemy from SVN (7576315169ccb8606f148d040c3602e1e21a04fd)
-
repo owner - changed status to wontfix
seems like the consensus here is worksforme
- Log in to comment
Is that your entire session? This works for me (and passes the doctest).