So basically, if I'm understanding the docs correctly, and what you just wrote:

Using the session object does not mean using the ORM. The ORM comes in play with Mapper and Mapped instances, which in turn require a primary key defined. So, I can use session.execute() to do non-ORM querying? And ResultProxy to work with returned data?

How would I autocreate the tables if I don't use Mapping, with DDL events and pure SQL?


Thanks.

.oO V Oo.


On 12/16/2011 10:03 PM, Jon Nelson wrote:
On Fri, Dec 16, 2011 at 2:55 PM, Vlad K.<v...@haronmedia.com>  wrote:
Hi all!

I have a few scenarios here that I believe are best solved without the ORM
overhead. For example, various log tables that do not require a primary key,
the rows are practically immutable, but are queried back for statistical
analysis. It is my understanding that I cannot use the ORM without a primary
key of some kind?

I am looking through the docs and I believe I should look into SQL
Expression Language section for that, am I correct? Which basically means I
should be using the expressions directly on the connection object
(connection.execute()) instead of using the sqlalchemy.orm.scoped_session
object?
I don't use scoped_session but I do use the sessionmaker "Session"
instances from the .orm namespace, and I rarely use the ORM itself.

My pattern usually goes like this:

session_factory = sa.orm.sessionmaker(....)
sess = session_factory()

sess.begin()
try:
   .. do stuff with sess
except:
   sess.rollback()
   grump loudly
   raise
else:
   sess.commit() # if appropriate, sometimes rollback
   sess.close() # probably unnecessary




--
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.

Reply via email to