I'm currently starting with sqlalchemy. In my current project I have to do some part with Flask and some other part from the command line. The part about flask is running fine, interfacing with sqlalchemy and all, but the commandline part is not.

The error I'm getting is

ArgumentError("Class object expected, got 'Table('documentos', 
 MetaData(bind=Engine(postgresql://user:password@localhost/clasificador)), 
 Column('id', Integer(), table=<documentos>, primary_key=True, nullable=False),
 Column('nombre', String(length=248), table=<documentos>), schema=None)'.",)

I've tried my luck with google and reading declarative sqlalchemy, but I can't find what could be the problem. The code in the module is:

from sqlalchemy.orm import sessionmaker
from db import engine,Base
#some other code
session = sessionmaker(bind=engine)
doc = modelos.documento.Documento(os.path.basename(nelto))
session.add(doc) #here fails
session.remove()

db is the module where I have the common code for sqlalchemy. most of it comes from flask documentation, and db_session is used only for flask, I made a different session for the other module.

from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base

sqldebug=True 

engine = create_engine( 
    'postgresql://user:passwd@localhost/clasificador',
    convert_unicode=True,
    echo=sqldebug)
db_session = scoped_session(sessionmaker(autocommit=False,
                                     autoflush=False,
                                     bind=engine))
Base = declarative_base(bind=engine)
Base.query = db_session.query_property()

Finally, here is the "documento" module, although I doubt the problem is here. from sqlalchemy import Column, Integer, String from db import Base

class Documento(Base):
    '''Clase definiendo los docu
Edit
Report