Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31969
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Nick Sabalausky <SeeWebsiteToContactMe@semitwist.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: SQLAlchemy: How to do Table Reflection and MySQL? |
| Date | Tue, 23 Oct 2012 19:15:16 -0400 |
| Organization | A noiseless patient Spider |
| Lines | 56 |
| Message-ID | <20121023191516.000021a2@unknown> (permalink) |
| References | <20121020192416.000023b6@unknown> <26471ad3-2bcd-46ed-a697-ae768eb5fd3b@m4g2000yqf.googlegroups.com> <20121023182831.000038ae@unknown> <mailman.2696.1351032152.27098.python-list@python.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| Injection-Info | mx04.eternal-september.org; posting-host="af24a2e39430ccc7e48f52be5dd29248"; logging-data="12615"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+6cwiyictj8LxgZC7MQG/9ASaGEYbbqKU=" |
| X-Newsreader | Claws Mail 3.8.0cvs30 (GTK+ 2.16.6; i586-pc-mingw32msvc) |
| Cancel-Lock | sha1:eCIRYVNKFNZhGO2lJ5RWXCbpxmY= |
| Xref | csiph.com comp.lang.python:31969 |
Show key headers only | View raw
On Tue, 23 Oct 2012 22:42:08 +0000
"Prasad, Ramit" <ramit.prasad@jpmorgan.com> wrote:
> Nick Sabalausky wrote:
> > On Mon, 22 Oct 2012 14:35:23 -0700 (PDT)
> > darnold <darnold992000@yahoo.com> wrote:
> > >
> > > i'm not brave enough to dig too deeply into SQLAlchemy, but maybe
> > > this will help? :
> > >
> > > http://kashififtikhar.blogspot.com/2010/07/using-sqlalchemy-reflection-with-pylons.html
> > >
> > > that came up from googling "sqlalchemy table reflection tutorial".
> >
> > Thanks, your view of Google seems to be far better tailored for
> > Python than mine is, that doesn't come up for me anywhere on the
> > first five pages of results for that query.
> >
> > Unfortunately the info on that page doesn't seem to work for me:
> >
> > ----------------------------------
> > from sqlalchemy import *
> > from sqlalchemy.orm import sessionmaker
> >
> > engine = create_engine(my connection string)
> > meta = MetaData()
> > meta.bind = engine
> > meta.reflect()
> >
> > Session = sessionmaker(bind=engine)
> > session = Session()
> >
> > res = session.query(user).filter(user.name=="bert").first()
> > print res.name
> > ----------------------------------
> >
> > That just gives me:
> >
> > NameError: name 'user' is not defined
> >
> > (And yes, the code given on that page to print out the table info
> > *does* indicate a table named 'user' was found.)
>
> This does not seem to be a SQLAlchemy problem. Instead it seems
> there is not a variable called `name`.
Oops, yea, it's supposed to be:
meta.tables["user"].columns["name"]
Not:
meta.tables["user"].name
Works now, thanks all.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
SQLAlchemy: How to do Table Reflection and MySQL? Nick Sabalausky <SeeWebsiteToContactMe@semitwist.com> - 2012-10-20 19:24 -0400
Re: SQLAlchemy: How to do Table Reflection and MySQL? darnold <darnold992000@yahoo.com> - 2012-10-22 14:35 -0700
Re: SQLAlchemy: How to do Table Reflection and MySQL? Nick Sabalausky <SeeWebsiteToContactMe@semitwist.com> - 2012-10-23 18:28 -0400
RE: SQLAlchemy: How to do Table Reflection and MySQL? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-10-23 22:42 +0000
Re: SQLAlchemy: How to do Table Reflection and MySQL? Nick Sabalausky <SeeWebsiteToContactMe@semitwist.com> - 2012-10-23 19:15 -0400
csiph-web