[sqlalchemy] Download a database's definitions?

2014-04-26 Thread Adam Morris
Hi there, Just wondering if there is some tool out there that will just connect to an existing database, do a bunch of magic, and output a file with the Table and Column objects all nice and defined for me? That way I can go about using column names in select statements, ect? The larger

Re: [sqlalchemy] Download a database's definitions?

2014-04-26 Thread Michael Bayer
if you actually want code generation there is sqlacodegen: https://pypi.python.org/pypi/sqlacodegen/1.1.4 On Apr 26, 2014, at 5:24 AM, Adam Morris adam.morris@gmail.com wrote: Hi there, Just wondering if there is some tool out there that will just connect to an existing database, do

[sqlalchemy] Relationship depending on a field in join table.

2014-04-26 Thread Peder Husom
Hi, I've been to the IRC channel and gotten alot of help from inklesspen, but I can't seem to figure this out. I have these tree tables; Users - iduser - name Companies - idcompany - name CompaniesUsers - companyid - userid - owner (TINYINT|Boolean) Now in my Company class I want

[sqlalchemy] sqlite3 recursivity

2014-04-26 Thread Richard Gerd Kuesters
hi all! as some already know, sqlite3 version 3.8.x (i'm not quite sure if it's 3.8.x, i might be wrong), but it has now support for recursivity using the with operator: https://sqlite.org/lang_with.html [1] well - probably mike can answear this better - will sqla provide basic support for

Re: [sqlalchemy] Relationship depending on a field in join table.

2014-04-26 Thread Michael Bayer
On Apr 26, 2014, at 10:59 AM, Peder Husom pederhu...@gmail.com wrote: Hi, I've been to the IRC channel and gotten alot of help from inklesspen, but I can't seem to figure this out. I have these tree tables; Users - iduser - name Companies - idcompany - name CompaniesUsers

Re: [sqlalchemy] sqlite3 recursivity

2014-04-26 Thread Michael Bayer
what happens if you just try it? the syntax looks entirely standard. On Apr 26, 2014, at 2:10 PM, Richard Gerd Kuesters rich...@humantech.com.br wrote: hi all! as some already know, sqlite3 version 3.8.x (i'm not quite sure if it's 3.8.x, i might be wrong), but it has now support for

Re: [sqlalchemy] Relationship depending on a field in join table.

2014-04-26 Thread Michael Bayer
On Apr 26, 2014, at 2:23 PM, Michael Bayer mike...@zzzcomputing.com wrote: If OTOH you do in fact want this query to take the current Company.id into account, this would be simple using primaryjoin/secondaryjoin/secondary, it just requires that the IN is unwrapped into a regular join

Re: [sqlalchemy] update where using the ORM

2014-04-26 Thread Tim Kersten
On Saturday, April 26, 2014 12:29:50 AM UTC+1, Michael Bayer wrote: On Apr 25, 2014, at 6:54 PM, Tim Kersten t...@io41.com javascript: wrote: This is an unusual use case because it seems like you’d like to outright ignore the row if it doesn’t match? or are you throwing an exception if

Re: [sqlalchemy] update where using the ORM

2014-04-26 Thread Michael Bayer
On Apr 26, 2014, at 3:26 PM, Tim Kersten t...@io41.com wrote: The resulting behaviour would be identical to using a version col id, but only for this transaction and the instance passed to the update_where() method, and instead of UPDATE ... WHERE pk = %s AND version = %s you'd have

[sqlalchemy] Binding base classes to different engines

2014-04-26 Thread Brian Findlay
My project requires querying an externally-managed database as well as a project-specific database. What I've been doing to date is copying the external database (which changes very infrequently) into the project-specific database so I only need one engine and one dbsession. I'm now trying to

[sqlalchemy] Re: Binding base classes to different engines

2014-04-26 Thread Brian Findlay
Not sure if __abstract__ is the way to go. Should I instead be creating mixins? http://docs.sqlalchemy.org/en/rel_0_9/orm/extensions/declarative.html#mixin-and-custom-base-classes On Saturday, April 26, 2014 5:07:23 PM UTC-4, Brian Findlay wrote: My project requires querying an

[sqlalchemy] Re: Binding base classes to different engines

2014-04-26 Thread Brian Findlay
Continuing to troubleshoot. This produces the same exception: DBSession.configure(binds={DB1: db1_engine, DB2: db1_engine}) Note that I'm binding both classes to the original engine. I thought it would be the same as the working config: DBSession.configure(bind=db1_engine) -- You received

Re: [sqlalchemy] Re: Binding base classes to different engines

2014-04-26 Thread Michael Bayer
the answer is simple in that the binds argument to Session precedes both Declarative as well as the advent of the __abstract__ keyword; it typically expects actual Mapper objects or classes from which a Mapper can be pulled directly. For now, you can instead override get_bind() to do whatever

Re: [sqlalchemy] Re: Binding base classes to different engines

2014-04-26 Thread Brian Findlay
Thanks, Mike. Will check this out. -- 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

Re: [sqlalchemy] Re: Binding base classes to different engines

2014-04-26 Thread Brian Findlay
I'm almost certainly exposing my level of ignorance here, but does this mean I could just replace DBSession.configure(binds={DB1:db1_engine, DB2:db2_engine}) with DBSession.configure(class_=MySession) ? I suppose I could even use DBSession = scoped_session(sessionmaker(class_=MySession,

Re: [sqlalchemy] Re: Binding base classes to different engines

2014-04-26 Thread Michael Bayer
On Apr 26, 2014, at 11:13 PM, Brian Findlay brian.m.find...@gmail.com wrote: I'm almost certainly exposing my level of ignorance here, but does this mean I could just replace DBSession.configure(binds={DB1:db1_engine, DB2:db2_engine}) with DBSession.configure(class_=MySession) ?