I'm trying to insert a list of dictionaries into a table using 
bulk_insert_mappings(). When I call it, I get this error:

AttributeError: 'Table' object has no attribute 'mapper'

I'm having trouble (in general) figuring out which of the various ways of 
specifying my table(s) are appropriate. I've been doing this (paraphrasing 
because I can't copy out of my work env):

    import sqlalchemy as sa
    import sa.orm

    SESSION = sa.orm.sessionmaker()
    engine = sa.create_engine(...)
    metadata = sa.MetaData(engine)
    session = SESSION(bind=engine)
    mytable = sa.Table("mytable", metadata, sa.Column(...), ...)

The session object is created within a contextmanager as described here:

http://docs.sqlalchemy.org/en/latest/orm/session_basics.html

It's within the scope of that contextmanager (a couple levels down in the 
function call stack) that the call is made:

    mytable = metadata.tables['mytable']
    session.bulk_insert_mappings(mytable, records)

I clearly must not understand something about the parameter properties 
required of that function. The docs state:

*mapper* – a mapped class, or the actual Mapper 
<http://docs.sqlalchemy.org/en/latest/orm/mapping_api.html#sqlalchemy.orm.mapper.Mapper>
 object, representing the single kind of object represented within the 
mapping list.

I thought I had assembled all the bits (engine, session, bound metadata). 
What's not mapped about my Table object?

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to