Re: [sqlalchemy] Doing reflection with multiple remote databases.

2013-01-16 Thread Hetii
The point is in that just some of them are identical, some others not, its 
more like sets of group models.One model is valid for 300 databases, 
another one for another 500 etc...

So i need a to have a fast way that will compare each database across the 
rest to see with one can be shared and then of course build it.


-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/YKsvHyl1qCEJ.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Doing reflection with multiple remote databases.

2013-01-16 Thread Michael Bayer
if you want some code you can adapt to compare schemas take a look at the 
autogenerate code in Alembic:

https://bitbucket.org/zzzeek/alembic/src/b0118a7df6ec71597b3b7849183768e4d59c9c49/alembic/autogenerate.py?at=default



On Jan 16, 2013, at 5:48 AM, Hetii wrote:

 The point is in that just some of them are identical, some others not, its 
 more like sets of group models.One model is valid for 300 databases, another 
 one for another 500 etc...
 
 So i need a to have a fast way that will compare each database across the 
 rest to see with one can be shared and then of course build it.
 
 
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 sqlalchemy group.
 To view this discussion on the web visit 
 https://groups.google.com/d/msg/sqlalchemy/-/YKsvHyl1qCEJ.
 To post to this group, send email to sqlalchemy@googlegroups.com.
 To unsubscribe from this group, send email to 
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sqlalchemy?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Doing reflection with multiple remote databases.

2013-01-16 Thread Claudio Freire
On Tue, Jan 15, 2013 at 8:48 PM, Hetii ghet...@gmail.com wrote:
 Even when i dump all of them into declarative base model, its still huge
 amount of data that need to be parsed and loaded.

 I want to ask if its possible to share table/column definition across
 different database models to reduce amount of used resources?

Even if you can't share the objects themselves (not sure you can, you
probably can't), you can share the code that generates them.

Remember python is dynamic, and class blah is code that actually
creates a class object:

def init():
   class Blah
   class Blah
   return locals()

globals().update(init())

^
You can call that init function as many times as you want. I use
something like that to map two identical databases (master and
replica) into two namespaces I can pick depending on the task.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Connections and Postgres

2013-01-16 Thread Henrique Nunes
Hi all!

I'm using SQLAlchemy to connect to a Postgres db on several Flask web 
applications, and I'm investigating connection leaking on them.

From running ps -ef I can see that, immediately after I start my web 
server, I immediately get one idle connection per web server worker process 
(gunicorn worker).

Now, on one app I'm not using Flask-SQLAlchemy, but scoped sessions 
directly. On the other I am using Flask-SQLAlchemy.

Initially I thought it was me not properly removing all the sessions after 
use, but the fact that the connections are up immediately after I start the 
servers, before any queries are made, is puzzling me... The fact that it 
happens with Flask-SQLAlchemy puzzles me even more since it was supposed to 
take care of removing sessions (even though, in this case, no request is 
actually made *before* the connection shows up on ps -ef).

Any thoughts on what might happening?

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/adroM3iiL6cJ.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Define a custom collection

2013-01-16 Thread Luca Wehrstedt
Done.

https://bitbucket.org/sqlalchemy/sqlalchemy/pull-request/36/fix-the-collectionlink-decorator

http://www.sqlalchemy.org/trac/ticket/2653

http://www.sqlalchemy.org/trac/ticket/2654

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/omr9KtOXjukJ.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Text column not populating on object correctly

2013-01-16 Thread Michael Bayer

On Jan 16, 2013, at 11:42 PM, jgruber wrote:

 I'm using SQLAlchemy 7.8 with sqlite3.  
 
 I have a Column setup in my schema of type Text, defined as follows:  
 
 marker_data = Column(Text(length=None, convert_unicode=False, 
 assert_unicode=None), nullable=False, unique=True)
 
 I create my object and I see the SQL generated just fine.  I have an external 
 sqlite client looking at the data and I see the table row populate correctly 
 with the marker_data column when I create objects through SQLAlchemy and 
 commit them.  However, the marker_data attribute on my python object for the 
 Text fields is set to 'None' as soon as I commit or read it again from the db.
 
 The text I put in is about 1700 characters and has '\n' characters in it. 
 Removing the '\n' characters didn't change the behaviour.
 
 When I use the engine by itself and do a raw query with engine.execute() the 
 tuple data for the Text field comes back just fine.  It seems to be the ORM 
 populating my object's marker_data attribute which isn't working?  
 
 Any ideas?  How do I troubleshoot this further?

there's something you're doing that is either setting this field to None or 
making it appear that way.   would need more details (like a test case) to see 
exactly what it is.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Text column not populating on object correctly

2013-01-16 Thread jgruber
I complete ripped up my code..  Working back through an argument to 
__init__ the object which inherits from my data model.. DUH!

Thanks.. found it. You were create =None killed it.. 

John

On Wednesday, January 16, 2013 10:56:44 PM UTC-6, Michael Bayer wrote:


 On Jan 16, 2013, at 11:42 PM, jgruber wrote: 

  I'm using SQLAlchemy 7.8 with sqlite3.   
  
  I have a Column setup in my schema of type Text, defined as follows:   
  
  marker_data = Column(Text(length=None, convert_unicode=False, 
 assert_unicode=None), nullable=False, unique=True) 
  
  I create my object and I see the SQL generated just fine.  I have an 
 external sqlite client looking at the data and I see the table row populate 
 correctly with the marker_data column when I create objects through 
 SQLAlchemy and commit them.  However, the marker_data attribute on my 
 python object for the Text fields is set to 'None' as soon as I commit or 
 read it again from the db. 
  
  The text I put in is about 1700 characters and has '\n' characters in 
 it. Removing the '\n' characters didn't change the behaviour. 
  
  When I use the engine by itself and do a raw query with engine.execute() 
 the tuple data for the Text field comes back just fine.  It seems to be the 
 ORM populating my object's marker_data attribute which isn't working?   
  
  Any ideas?  How do I troubleshoot this further? 

 there's something you're doing that is either setting this field to None 
 or making it appear that way.   would need more details (like a test case) 
 to see exactly what it is.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/K6mArBXwxLEJ.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.