That worked! Thank you so much for your patience. Part of it was the
code, and part of it turned out to be that I was still using
vendorTable = base.classes.VENDR
It didn't occur to me that my VENDR class had taken over that part, so
base.classes would no longer contain VENDR. When I saw your asse
metadata.reflect(..., extend_existing=True), here's a complete example
from sqlalchemy import create_engine
e = create_engine("mssql+pyodbc://scott:tiger@ms_2008", echo=True)
with e.begin() as conn:
conn.execute("""
if not exists (select * from sysobjects where name='sometable'
an
I hate to say it, but... AttributeError: VENDR. I've moved different
lines all around, above and below the class definition, but nothing
I've tried works. The only change was when I put my declaration of
base below the class, and Python naturally said it didn't know what my
table class was inheriti
oh. try it like this:
class VENDR(base):
__tablename__ = "VENDR"
PVVNNO = sqlalchemy.Column(sqlalchemy.String, primary_key=True)
__table_args__ = {"extend_existing": True}
that tells reflection to add new data to this Table object even though
it already exists.
On 03/14/2016 09:24
Thanks for that. Somehow, I'm getting the same error as before--the
VENDR table isn't being reflected. Here's the entire snippet, from
engine to trying to get the table.
engine = sqlalchemy.create_engine("mssql+pyodbc://%s:%s@%s"
%(username, password, dsn))
session = Session(engine)
metadata = sql
like this:
class VENDR(MyAutomapBase):
__tablename__ = 'VENDR'
id = Column(Integer, primary_key=True)
Above, the 'id' column name should match the column in the table that
you'd like to consider as the primary key (and so should the type) - the
"id" / "Integer" combination above is ju
Sorry, do you mean the base subclass, or a new table class? In either
case, I'm not sure I see how this will fit into my automapping code. I
know this is all fairly basic, I just can't quite picture what goes
where and what inherits from/gets passed to what to make it automap
this VENDR table. If I
just make the class and include the PK column, then automap. the rest
of the columns should be filled in.
On 03/11/2016 04:14 PM, Alex Hall wrote:
Ah, you're right. Every other table I've used in this database has had
a key, and I didn't even notice that this VENDR table lacks one. That
expla
Ah, you're right. Every other table I've used in this database has had
a key, and I didn't even notice that this VENDR table lacks one. That
explains the mystery! Thanks.
Now to map this table. I've read the section of the docs on doing
this, and I get that I subclass base, set __table__ to be my
ah. does VENDR have a primary key? it won't be mapped if not.
what's in base.classes.keys() ? base.classes['VENDR'] ?
On 03/11/2016 12:47 PM, Alex Hall wrote:
VENDR is right there, in base.classes and metadata.tables. Yet,
vendorTable = base.classes.VENDR
raises an AttributeError. Odd
VENDR is right there, in base.classes and metadata.tables. Yet,
vendorTable = base.classes.VENDR
raises an AttributeError. Odd! There's nothing cap-sensitive about
__hasattr__ that I'm forgetting, is there? Or, could I somehow alias
the name before I try to access it, if that would help at all? Thi
can you look in metadata.tables to see what it actually reflected ?
On 03/11/2016 12:09 PM, Alex Hall wrote:
That's weird: the name I see is exactly what I've been using, "VENDR".
All caps and everything. I tried using lowercase, just to see what it
would do, but it failed.
On 3/11/16, Mi
On 03/11/2016 09:39 AM, Alex Hall wrote:
Hello list,
Finally, a pure SA question from me. I'm using Automap and the "only"
keyword to automap a subset of the tables in our CMS database. This
has worked perfectly thus far. Now, though, it's failing on a specific
table, and the only difference I
That's weird: the name I see is exactly what I've been using, "VENDR".
All caps and everything. I tried using lowercase, just to see what it
would do, but it failed.
On 3/11/16, Mike Bayer wrote:
>
>
> On 03/11/2016 09:39 AM, Alex Hall wrote:
>> Hello list,
>> Finally, a pure SA question from me.
Hello list,
Finally, a pure SA question from me. I'm using Automap and the "only"
keyword to automap a subset of the tables in our CMS database. This
has worked perfectly thus far. Now, though, it's failing on a specific
table, and the only difference I can see is that this table's name is
in all c
15 matches
Mail list logo