Yes, I'm using Declarative. I was following a great tutorial, then
realized it was way out of date. The one recommended on the forum I
found said to use Declarative, so I did.
In DBInterface, I have this little function:
def getAllTables():
return base.metadata.tables
#end def getAllTables
I
SQLAlchemy has 2 main layers, the "Core" layer which deals with mostly
database-level constructs, such as Tables, and the ORM layer, which is
built on top of Core. With the ORM, you map your own classes onto the
lower-level Tables, then work with instances of those classes. You appear
to be using
On Thursday, February 4, 2016 at 9:36:43 AM UTC-5, Michael Bayer wrote:
You might find it a better approach overall to use a separate Session
> for persistence, have your users deal with entirely detached objects and
> then just copy their state to the Session when you're ready to persist
>
> On 4 Feb 2016, at 18:19, Alex Hall wrote:
>
> Hello all,
> I'm setting my application up the way Simon suggested. I still use the
> table object so I can get its name for displaying in one list, but the
> other list (which holds the actual rows of the selected table) is
>
Ah, getattr()… I forgot that one! It's a bit messy, but my tables now fill
correctly:
recordData = getattr(record, table.columns.keys()[i].__str__()).__str__()
Maybe one day I'll make my table schemas (is that the right term for them?)
itterable, but this works for now. Thanks for the help. I
Oh! Okay, I think I get you now. The only reason I pass a list of
table objects is that I need the name, and I thought I needed the
table to query. If I can obtain the table name from the class
(.__tablename__), then this should work, with no need to mess with
table objects at all. I'll try it.
I was re-reading your email, and realized I forgot to answer something
(sorry, it's early here). It looks like I am indeed passing the table
to session.query, which works, but then I'm trying to change
attributes of the table, which doesn't (of course). Could I do this?
#DBDefinitions.py
import
On 02/03/2016 11:10 PM, James Emerton wrote:
im not sure why you need to use begin() at all? in autocommit mode, the user
presses save, you just call flush(). flush() always uses a transaction
internally. That's originally how the Session was meant to be used, having an
explicitly
You need to use the class when querying the database. SQLAlchemy will then
return an instance of that class for each matching row:
customer = session.query(Customer).filter_by(name=u'Powersports
Etc').first()
customer.name = u'New Name'
session.flush()
The getAllClasses function I showed
getAllTables is returning Core Table objects. I suppose you could have a
similar function which returns all mapped classes, something like this:
def getAllClasses():
return base.__subclasses__()
(If your class hierarchy is more complicated you'd need a more
sophisticated function there)
This is where sqlalchemy gets murky for me. If I return all classes,
I'm not returning all *instances* of those classes. How, then, would I
update a given customer's record? The objects (c1 and c2, for
instance) were instantiated elsewhere, and my GUIManager module has no
knowledge of them. More
On 02/04/2016 12:34 PM, Daniel Cochran wrote:
Hi Michael -- thank you for the reply.
everything looks fine, except what does get_sqlAlchemy() do? If that
creates a new SqlAlchemy instance each time, then you're making new
connection pools on every request. even then, when
Hi Michael -- thank you for the reply.
everything looks fine, except what does get_sqlAlchemy() do? If that
> creates a new SqlAlchemy instance each time, then you're making new
> connection pools on every request. even then, when these are garbage
> collected the underlying database
Hello all,
I'm setting my application up the way Simon suggested. I still use the
table object so I can get its name for displaying in one list, but the
other list (which holds the actual rows of the selected table) is
using the relevant subclass of base.
I use wx.ListCtrl to display everything,
14 matches
Mail list logo