#!/usr/bin/python # -*- coding: UTF-8 -*- from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base() class Test(Base): __tablename__ = 'test' tid = Column(Integer) engine = create_engine('sqlite:///:memory:', echo=True) metadata = Base.metadata metadata.create_all(engine) ========================================================== When i run it: Traceback (most recent call last): File "D:\z_CaiJi_\z6.py", line 10, in <module> class Test(Base): File "c:\python25\lib\site-packages\SQLAlchemy-0.5.8-py2.5.egg \sqlalchemy\ext\declarative.py", line 561, in __init__ _as_declarative(cls, classname, dict_) File "c:\python25\lib\site-packages\SQLAlchemy-0.5.8-py2.5.egg \sqlalchemy\ext\declarative.py", line 554, in _as_declarative cls.__mapper__ = mapper_cls(cls, table, properties=our_stuff, **mapper_args) File "c:\python25\lib\site-packages\SQLAlchemy-0.5.8-py2.5.egg \sqlalchemy\orm\__init__.py", line 751, in mapper return Mapper(class_, local_table, *args, **params) File "c:\python25\lib\site-packages\SQLAlchemy-0.5.8-py2.5.egg \sqlalchemy\orm\mapper.py", line 199, in __init__ self._configure_pks() File "c:\python25\lib\site-packages\SQLAlchemy-0.5.8-py2.5.egg \sqlalchemy\orm\mapper.py", line 440, in _configure_pks "key columns for mapped table '%s'" % (self, self.mapped_table.description)) sqlalchemy.exc.ArgumentError: Mapper Mapper|Test|test could not assemble any primary key columns for mapped table 'test' It seems must make a primary_key for table,but my table need't primary_key,what can i do? -- 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.