[sqlalchemy] django user (using django ORM) + sqlalchemy for other db tables

2013-09-09 Thread Dennis
Any advice (or potential problems) with using sqlalchemy with the django 
framework but keeping the django user auth module?

The django ORM would be used for the auth module (and its user table).
SqlAlchemy ORM would be used for other tables and also to read (but not 
write) the django user table.

This combination would allow the power of sqlachemy but maintain 
compatibility with django auth -- a sweet combination!
Of course, the django admin system would likely not work, but that's ok.

Just wondering if others have tried this and what issues might have come up.

This approach is described in the stackoverflow comment here:
http://stackoverflow.com/questions/18465197/how-do-i-start-with-django-orm-to-easily-switch-to-sqlalchemy#comment27166795_18476898

The method to integrate sqlalchemy into django is described here:
http://stackoverflow.com/questions/6606725/best-way-to-integrate-sqlalchemy-into-a-django-project

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.


[sqlalchemy] Re: django user (using django ORM) + sqlalchemy for other db tables

2013-09-09 Thread Dennis
PS: from my google searching, the 2 references below (and their references) 
are really the only mention of this approach on the web!
So, it would be great to get some definitive advice on this seemly 
reasonable approach.



On Monday, September 9, 2013 6:04:23 PM UTC+8, Dennis wrote:

 Any advice (or potential problems) with using sqlalchemy with the django 
 framework but keeping the django user auth module?

 The django ORM would be used for the auth module (and its user table).
 SqlAlchemy ORM would be used for other tables and also to read (but not 
 write) the django user table.

 This combination would allow the power of sqlachemy but maintain 
 compatibility with django auth -- a sweet combination!
 Of course, the django admin system would likely not work, but that's ok.

 Just wondering if others have tried this and what issues might have come 
 up.

 This approach is described in the stackoverflow comment here:

 http://stackoverflow.com/questions/18465197/how-do-i-start-with-django-orm-to-easily-switch-to-sqlalchemy#comment27166795_18476898

 The method to integrate sqlalchemy into django is described here:

 http://stackoverflow.com/questions/6606725/best-way-to-integrate-sqlalchemy-into-a-django-project


-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [sqlalchemy] query question

2013-09-09 Thread lars van gemerden
Ok, i've tried both (and each separately), as in:

r1 = Report(number = 1, title = The Bird) 
r2 = Report(number = 2, title = The Bucket)
session.add_all([r1, r2])
session.commit()
q = self.session.query(Report.title)
q.with_entities(Report.number)
q.add_columns(Report.number)
print q.all()

printing:

[(u'The Bird',), (u'The Bucket',)]

what i would like to see is:

   [(u'The Bird', 1), (u'The Bucket', 2)]
 
or something similar.

Cheers, Lars

On Wednesday, September 4, 2013 1:24:28 PM UTC+2, Simon King wrote:

 On Wed, Sep 4, 2013 at 12:05 PM, lars van gemerden 
 la...@rational-it.comjavascript: 
 wrote: 
  I  think i must be reading over something, but: 
  
  is there a way to delay the selection of attributes in a query; 
 something 
  like 
  
session.query(Person).filter(Person.age  
  100).select(Person.name).first() 
  
 (uAncient Bob,) 
  

 I'm not sure quite what you mean, but the with_entities method of 
 Query would seem to be the closest to your example: 

   
 http://docs.sqlalchemy.org/en/rel_0_8/orm/query.html#sqlalchemy.orm.query.Query.with_entities
  

 I assume you know you can also do this: 

   session.query(Person.name).filter(Person.age  100).first() 

 You can also defer certain columns so that they will be loaded lazily: 

   
 http://docs.sqlalchemy.org/en/rel_0_8/orm/mapper_config.html#deferred-column-loading
  

 Hope that helps, 

 Simon 


-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [sqlalchemy] query question

2013-09-09 Thread lars van Gemerden
OK, never mind |-)

should be:

   q = q.with_entities(Report.number)
   q = q.add_columns(Report.number)

sry



On Mon, Sep 9, 2013 at 2:43 PM, lars van gemerden l...@rational-it.comwrote:

 Ok, i've tried both (and each separately), as in:

 r1 = Report(number = 1, title = The Bird)
 r2 = Report(number = 2, title = The Bucket)
 session.add_all([r1, r2])
 session.commit()
 q = self.session.query(Report.title)
 q.with_entities(Report.number)
 q.add_columns(Report.number)
 print q.all()

 printing:

 [(u'The Bird',), (u'The Bucket',)]

 what i would like to see is:

[(u'The Bird', 1), (u'The Bucket', 2)]

 or something similar.

 Cheers, Lars

 On Wednesday, September 4, 2013 1:24:28 PM UTC+2, Simon King wrote:

 On Wed, Sep 4, 2013 at 12:05 PM, lars van gemerden la...@rational-it.com
 wrote:
  I  think i must be reading over something, but:
 
  is there a way to delay the selection of attributes in a query;
 something
  like
 
session.query(Person).filter(**Person.age 
  100).select(Person.name).**first()
 
 (uAncient Bob,)
 

 I'm not sure quite what you mean, but the with_entities method of
 Query would seem to be the closest to your example:

   http://docs.sqlalchemy.org/en/**rel_0_8/orm/query.html#**
 sqlalchemy.orm.query.Query.**with_entitieshttp://docs.sqlalchemy.org/en/rel_0_8/orm/query.html#sqlalchemy.orm.query.Query.with_entities

 I assume you know you can also do this:

   session.query(Person.name).**filter(Person.age  100).first()

 You can also defer certain columns so that they will be loaded lazily:

   http://docs.sqlalchemy.org/en/**rel_0_8/orm/mapper_config.**
 html#deferred-column-loadinghttp://docs.sqlalchemy.org/en/rel_0_8/orm/mapper_config.html#deferred-column-loading

 Hope that helps,

 Simon

  --
 You received this message because you are subscribed to a topic in the
 Google Groups sqlalchemy group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/sqlalchemy/7hA4UZV8uaA/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 sqlalchemy+unsubscr...@googlegroups.com.
 To post to this group, send email to sqlalchemy@googlegroups.com.
 Visit this group at http://groups.google.com/group/sqlalchemy.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 

Lars van Gemerden
l...@rational-it.com
+31 6 26 88 55 39


-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.


[sqlalchemy] Re: django user (using django ORM) + sqlalchemy for other db tables

2013-09-09 Thread Jonathan Vanasco
Honestly, I wouldn't do this.

Django has a lot of magic under the hood, and it's ORM does some very 
specific things to make this magic happen.  It's not just the auth, it's 
how everything is structured in the database and how the app integrates 
with the database.  You're likely to break things and be miserable.  Django 
, Rails, etc are all-in frameworks -- they provide a stack with several 
decisions made for you; it's all or nothing.

I'd personally suggest you either:

- Continue using Django with their ORM.  Create a secondary model that uses 
SqlAlchemy to reflect the Django mapping.  That will let you use SqlAlchemy 
to do advanced read queries.

- Use a different framework ( Pyramid, Flask, etc ; many have auth plugins 
that work with SqlAlchemy models )


-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [sqlalchemy] Re: django user (using django ORM) + sqlalchemy for other db tables

2013-09-09 Thread Mauricio de Abreu Antunes
The major problem is: everything in Django is mapped to the ORM. Even the
sessions. Sorry for being negative but that is my way to understand this.


2013/9/9 Jonathan Vanasco jonat...@findmeon.com

 Honestly, I wouldn't do this.

 Django has a lot of magic under the hood, and it's ORM does some very
 specific things to make this magic happen.  It's not just the auth, it's
 how everything is structured in the database and how the app integrates
 with the database.  You're likely to break things and be miserable.  Django
 , Rails, etc are all-in frameworks -- they provide a stack with several
 decisions made for you; it's all or nothing.

 I'd personally suggest you either:

 - Continue using Django with their ORM.  Create a secondary model that
 uses SqlAlchemy to reflect the Django mapping.  That will let you use
 SqlAlchemy to do advanced read queries.

 - Use a different framework ( Pyramid, Flask, etc ; many have auth plugins
 that work with SqlAlchemy models )


  --
 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 sqlalchemy@googlegroups.com.
 Visit this group at http://groups.google.com/group/sqlalchemy.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
*Mauricio de Abreu Antunes*
*
*
Github: https://github.com/mauricioabreu
Twitter: https://twitter.com/maugzoide

-- 
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 sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.