[sqlalchemy] Re: SQLAlchemy 0.8.3 / 0.9.0b1 released

2013-10-26 Thread Jonathan Vanasco
Thanks! -- 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.

Re: [sqlalchemy] Getting the unmodified version of an object without losing changes

2013-10-24 Thread Jonathan Vanasco
I had a similar needs with generating diffs for tracking revision history a while back I ended up pushing everything into a mixin class. It worked a little like this... class MutatedChecknObject(object): def generate_diff(self): insp = sqlalchemy_inspect(self)

Re: [sqlalchemy] is ForeignKey() the only ORM feature (outside of table setup) that requires table knowledge

2013-10-24 Thread Jonathan Vanasco
Thanks for the history lesson! A large part of me things that both strings or objects should be accepted , this way there would be parity across the board. Because yes, it is confusing! But a larger part of me worries about backwards compatibility and collisions. ForeignKey(mytable.id)

[sqlalchemy] is ForeignKey() the only ORM feature (outside of table setup) that requires table knowledge

2013-10-23 Thread Jonathan Vanasco
this has just confused me for a while , and constantly trips me up... class FirstTable() __tablename__ = 'first_table' id = Column(Integer, primary_key=True) class SecondTable() __tablename__ = 'second_table' id = Column(sa.Integer, primary_key=True)

Re: [sqlalchemy] Re: most established SQLA fixture tools?

2013-10-17 Thread Jonathan Vanasco
I don't , but should. I've just used database dumps and a homebrew system, because tools like this didn't exist when I first needed them. BUT it seems to offer the same functionality as Rails/Django migrations , which you will eventually need in your new Django-favoring environment. -- You

[sqlalchemy] Re: most established SQLA fixture tools?

2013-10-16 Thread Jonathan Vanasco
I saw this a while back: https://pypi.python.org/pypi/mixer/1.1.6 which claims to handle both Django SqlAlchemy, so it might be more familiar to them. there are a few fixtures projects for Sqlalchemy on PyPi I *think* you might be able to get away with some stuff using Alembic, but

Re: [sqlalchemy] locking tables with orm? need to generate PK manually...

2013-10-16 Thread Jonathan Vanasco
FYI , you can also drop SqlAlchemy core/engine commands within the `connection.execute()` and reference the ORM connection.execute( model.core.Client.__table__\ .update()\ .where( model.core.Client.id == id )\ .values( lastupdate = NOW() ) ) it's a little

[sqlalchemy] DataError: (DataError) integer out of range

2013-10-14 Thread Jonathan Vanasco
I just got this error on a query: DataError: (DataError) integer out of range ( along with the query ) Is there any way to get the details of which column failed ? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group

[sqlalchemy] Re: DataError: (DataError) integer out of range

2013-10-14 Thread Jonathan Vanasco
This might be moot - PostgreSQL doesn't seem to show which column failed in their command-line tool. [sidenote: I did know what the problem was - an INT column where BIGINT was appropriate - the error reporting just seemed too generic ] -- You received this message because you are subscribed

[sqlalchemy] Re: Session creation without scoped session?

2013-10-10 Thread Jonathan Vanasco
It won't answer your question, but you should read the 2 links mike pointed me to over here: https://groups.google.com/d/msg/sqlalchemy/ZsHxDzlATCQ/sQvnAORluMsJ -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and

[sqlalchemy] building a 'complex' relationship ?

2013-10-09 Thread Jonathan Vanasco
I'm not sure if this is possible. I was hoping it was, but my attempts so far didn't work. I've got a separate select going, but would love to pare things down to one. I'm wanting to map a relationship where two columns match ( not one ) and there is a boolean filter Class Author: id =

[sqlalchemy] Re: building a 'complex' relationship ?

2013-10-09 Thread Jonathan Vanasco
primaryjoin = and_(Article.author_id == AuthorOverride.author_id , Article.topic_id == AuthorOverride.topic_id , AuthorOverride.is_published == True) , foreign_keys = ( Article.author_id , Article.topic_id), Solved . I was close. 1. Wrap the join conditions in

Re: [sqlalchemy] Re: using SQLA in distributed, concurrent, or asynchronous contexts?

2013-10-07 Thread Jonathan Vanasco
From my understanding, this should be safe with Twisted: - SqlAlchemy engine operations, where you don't use the ORM and encapsulate every ansync chunk in a transaction, and within a thread - SqlAlchemy orm operations, where every async chunk is encapsulated in it's own session, and within a

Re: [sqlalchemy] Re: using SQLA in distributed, concurrent, or asynchronous contexts?

2013-10-07 Thread Jonathan Vanasco
On Monday, October 7, 2013 8:27:34 PM UTC-4, Klauss wrote: 3- open a single request-scope session, and carry it through your async tasks. I left that out, because it brings up the problem where your long-running session blocks the database (via transactions) or if you're in some

Re: [sqlalchemy] Query for date between a range

2013-10-04 Thread Jonathan Vanasco
That query looks weird. I'd suggest converting everything to a date in the database and having the db sort it -- on postgres it would look like this -- create table test_date ( id serial primary key not null , int , mm int , dd int ); select * from test_date where (

[sqlalchemy] Re: using SQLA in distributed, concurrent, or asynchronous contexts?

2013-10-03 Thread Jonathan Vanasco
So the No SqlAlchemy with Twisted approach is dated. I've been on the twisted list for a while, and recently asked it -- as i have a bit of stuff for the same project running in twisted as-well-as pyramid and-also celery. The current consensus is that it's a general no-go/bad-idea if you're

[sqlalchemy] Re: using SQLA in distributed, concurrent, or asynchronous contexts?

2013-10-03 Thread Jonathan Vanasco
Also, a decent strategy to use is this: a) Your client does a lot of business logic in Pyramid. When you need to bill you hit an internal API or create a celery task b) You render a waiting page, and have ajax, or refresh, check to see if the internal API , or celery, is done processing c)

Re: [sqlalchemy] Using session.execute to bulk-insert into MySQL

2013-10-01 Thread Jonathan Vanasco
do you recall if `flush()` initiated 'mark_changed' at some point in history? i thought it did. -- 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] Re: Using session.execute to bulk-insert into MySQL

2013-09-30 Thread Jonathan Vanasco
I think the issue might be related to this: https://github.com/zopefoundation/zope.sqlalchemy/blob/master/src/zope/sqlalchemy/datamanager.py#L213 Record that a flush has occurred on a session's connection. This allows the DataManager to rollback rather than commit on read only transactions.

Re: [sqlalchemy] textcolumn.contains() escaping, the lack of icontains(), and possible bug?

2013-09-27 Thread Jonathan Vanasco
Any progress on considering: * icontains * istartswith * iendswith I ran into this again ( i had posted a similar request about a year or so ago ) re But then what do we do on a backend that doesn't have ilike? do we raise an error? would this be possible: .filter(

Re: [sqlalchemy] timing / profiling object loading ?

2013-09-27 Thread Jonathan Vanasco
funny- I never noticed the time column in pyramid_debugtoolbar -- I use it all the time ! i ended up doing a lot of my profiling outside of pyramid though. that's something i really love about sqlalchemy (and pyramid) - once the models were built, I could just import them into test scripts

Re: [sqlalchemy] timing / profiling object loading ?

2013-09-26 Thread Jonathan Vanasco
yeah. painfully slow. i can't seem to recreate this on a test script. it happens every so often in a pyramid app , but I can't recreate it on a bootstrapped (command line) pyramid instance. my test suite shows this happening instantly. this has been troubling me for over a week since i

Re: [sqlalchemy] timing / profiling object loading ?

2013-09-26 Thread Jonathan Vanasco
Thanks. I caved in and stayed up until 3am last night to add a ton of log.debug() statements across the app. The culprit was my read-through-caching layer ( built on dogpile ). It was implemented in such a way that SqlAlchemy looked to have issues. The performance on the DBM datatstore was

Re: [sqlalchemy] timing / profiling object loading ?

2013-09-26 Thread Jonathan Vanasco
On Thursday, September 26, 2013 11:58:26 AM UTC-4, Michael Bayer wrote: That's why I don't have a caching function included with SQLAlchemy. Because then I'd be debugging it, not you :) Ha! My caching is pretty lightweight. I do need to figure out a better system though -- that's for

[sqlalchemy] Re: Sqlalchemy sintax for a query with not like operator

2013-09-26 Thread Jonathan Vanasco
i think this should work: query.filter( ~ table.column.contains('%value2%') ) -- 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] Re: How to not losing changes on rollback?

2013-09-25 Thread Jonathan Vanasco
I'd be interested in this too. FWIW, my approach is this: - flush often - encapsulate complex logic in 'savepoints' , roll back to them - fail everything and start from scratch on other errors -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To

[sqlalchemy] timing / profiling object loading ?

2013-09-25 Thread Jonathan Vanasco
is there a way to time the time spent 'loading' an object from the database ? i think there might be a bottleneck in a part of my application that is related to the object instantiation. just to be clear , in this flow: a) `query.all()` b) sqlalchemy compiles query c) sqlalchemy to db

Re: [sqlalchemy] timing / profiling object loading ?

2013-09-25 Thread Jonathan Vanasco
very good. thanks. i accidentally left a LIMIT off a query. The DB was optimized to return the results in about .003s ; but it seems to have taken about 2 minutes for sqlalchemy to generate ~1300 objects from the rows. -- You received this message because you are subscribed to the Google

Re: [sqlalchemy] another postgresql distinct on question

2013-09-23 Thread Jonathan Vanasco
On Monday, September 23, 2013 10:31:16 AM UTC-4, Michael Bayer wrote: it will definitely show the right thing for echo=True, that's what's being sent to the database. yeah, the `echo` in my debug log is what showed me that postgres was getting the right data. i was doing this to audit

Re: [sqlalchemy] another postgresql distinct on question

2013-09-22 Thread Jonathan Vanasco
ah ha! yes! that is right. query = select( (these,columns,) ).distinct( this.column ) this was an even tricker problem... and I might have been executing correct queries last night without realizing it. i just noticed that i was getting a correct query in my database, while I was

[sqlalchemy] Re: What is the proper way to return the deleted records synchronously?

2013-09-22 Thread Jonathan Vanasco
Assuming you're in the ORM, there's also a per-instance delete : http://docs.sqlalchemy.org/en/rel_0_8/orm/events.html#sqlalchemy.orm.events.MapperEvents.after_delete but `session.query().delete()` suggests you don't want to load objects into the ORM, and just want to delete things matching a

Re: [sqlalchemy] (newb) approach to localization

2013-09-21 Thread Jonathan Vanasco
This bit... title = obj.title[en-US] # or something similar that's very close to how PostgreSQL's HSTORE and JSON columns work with sqlalchemy. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop

[sqlalchemy] another postgresql distinct on question

2013-09-21 Thread Jonathan Vanasco
I can't seem to generate a distinct on(column) query ( .8 branch ) i'm using a connection with an ORM session , and working on an alias this just creates a SELECT DISTINCT column sqlalchemy.select( sqlalchemy.distinct(_slurped.c.object_id).label('object_id') , _ordered.c.event_timestamp)

Re: [sqlalchemy] api omission? the postgres DISTINCT ON(columns) is only in the ORM, not in the sql expression

2013-09-19 Thread Jonathan Vanasco
Oh crap. I understand. I was trying to do this: query = select( func.distinct( columns ) ) and not query = distinct( columns ) i got thrown off, because the postgres tool is more like a function than an query , and there's also the .distinct() method you can toss onto a query;

[sqlalchemy] Re: Running SQL Alchemy on a QNX RTOS Machine

2013-09-18 Thread Jonathan Vanasco
http://docs.sqlalchemy.org/en/rel_0_8/dialects/index.html Current external dialect projects for SQLAlchemy include: * sqlalchemy-access https://bitbucket.org/zzzeek/sqlalchemy-access - driver for Microsoft Access. https://bitbucket.org/zzzeek/sqlalchemy-access On Wednesday, September 18,

[sqlalchemy] advanced orm join advice - union + alias

2013-09-18 Thread Jonathan Vanasco
I'm using the ORM ( though I could be using expressions ) , and have a bit of code that simply queries for an id + timestamp [ against a join of 6 tables ] i have another bit of code that performs a similar function. all is well. I need to , now, join the two codes, and create sql like such :

[sqlalchemy] Re: advanced orm join advice - union + alias

2013-09-18 Thread Jonathan Vanasco
This is horrible, but it works ( after a few hours of trial error ) the trick was in using labels and aliases in every step it makes perfect sense looking at it now ( though ugly ), but was not how i expected to pull this off. For anyone who gets stuck: if _query_A and _query_B :

[sqlalchemy] api omission? the postgres DISTINCT ON(columns) is only in the ORM, not in the sql expression

2013-09-18 Thread Jonathan Vanasco
this tripped me up when i was working on some queries. orm : distinct( column ) = DISTINCT ON (column) core : distinct( column ) = DISTINCT (column) there doesn't seem to be an easy way to write DISTINCT ON (column) in the orm -- You received this message because you are

[sqlalchemy] timing queries ?

2013-09-17 Thread Jonathan Vanasco
is there a currently recommended approach ? looking through the backcatalog of qa (from 2008-2010) , it seems like the options are: - manually look at debug data , subtract timestamps for a general idea - write something with ConnectionEvents ( originally ConnectionProxy ) for now, i just want

Re: [sqlalchemy] timing queries ?

2013-09-17 Thread Jonathan Vanasco
it might be better for the recipe to be: logger = logging.getLogger(sqlalchemy.engine.base.Engine) logger.setLevel(logging.INFO) logger.info(Query Complete! Total Time: %f % total) This will correlate it to the existing sql statement logging ( which is a way more natural place

Re: [sqlalchemy] timing queries ?

2013-09-17 Thread Jonathan Vanasco
On Tuesday, September 17, 2013 3:59:31 PM UTC-4, Michael Bayer wrote: there's a modern recipe at: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/Profiling but yeah, thats ConnectionEvents. what's the issue there, you need how long result fetching takes ? thanks! yeah. Some of the

Re: [sqlalchemy] Mutable column_properties

2013-09-12 Thread Jonathan Vanasco
I just spend 30mins with pdb; I was wrong ; I think it would be way too hard to get it into the ORM. The way MutableDict seems to be currently integrated, the entire value is updated for the key , and the original value seems to be obliterated. Outside of the ORM -- do you have any references

[sqlalchemy] Re: Mutable column_properties

2013-09-12 Thread Jonathan Vanasco
I might be interpreting all this wrong, but I don't think the column_property needs to be writable. I think the situation is this: Under Postgres, with HSTORE it's possible to INSERT/UPDATE/DELETE only certain values from within the store. Under SqlAlchemy, the entire object is

[sqlalchemy] Re: Mutable column_properties

2013-09-12 Thread Jonathan Vanasco
Actually, this is more correct for multi-key updates: -- select before update SELECT id, kv-'x' AS kv_x , kv-'y' AS kv_y , kv-'z' AS kv_z FROM test_class ; -- update 2 columns ; these 3 are identical kvkv UPDATE test_class SET kv = kv || hstore(ARRAY['z','zz','x','xx']);

Re: [sqlalchemy] Mutable column_properties

2013-09-12 Thread Jonathan Vanasco
Sweet. This works : results = dbSession.execute( TestClass.__table__\ .update()\ .values( kv = TestClass.__table__.c.kv + sqlalchemy.dialects.postgresql.hstore(sqlalchemy.dialects.postgresql.array(['zz123', 'zz123'])) ) ) stmt = select( [

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

2013-09-10 Thread Jonathan Vanasco
On Tuesday, September 10, 2013 6:47:41 AM UTC-4, Dennis wrote: Thanks for the advice -- your recommendations against this configuration were a surprise to me... It's making me rethink what I want (and how much I want it). I'll post this as a comment to the first stackoverflow question so

[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

Re: [sqlalchemy] How-to filter by the time part of a datetime field?

2013-08-30 Thread Jonathan Vanasco
In addition to using `func.*` methods, there's also the `extract` method that works (in most databases) specifically on datetime objects. sqlalchemy.sql.expression.extract(*field*,

Re: [sqlalchemy] Calculate birthdays

2013-08-30 Thread Jonathan Vanasco
that's less of a SqlAlchemy question and more of a general database question. there are a handful of approaches on StackOverflow, and the easier approach can differ across databases. try searching for birthdate/birthday range and postgresql or mysql . I'd suggest that you find one there,

Re: [sqlalchemy] sqlite string concats and datetime arithmetics

2013-08-30 Thread Jonathan Vanasco
This might be a bug then. String || Integer ; Integer || String - PostgreSQL and sqlite both allow for a sting integer to be concat together into a string. Order does not matter. Integer || Integer - PostgreSQL will error if 2 ints are concat together. - sqlite seems to cast both into a

[sqlalchemy] Re: Can you count the active/open sessions?

2013-08-29 Thread Jonathan Vanasco
in general , It's worth reading these 2 sections of the docs if you haven't already : http://docs.sqlalchemy.org/en/rel_0_8/orm/session.html#session-frequently-asked-questions http://docs.sqlalchemy.org/en/rel_0_8/orm/session.html#using-thread-local-scope-with-web-applications -- You received

Re: [sqlalchemy] watining for table metadata lock

2013-08-29 Thread Jonathan Vanasco
MyISAM doesn't support transactions, but it does support locking. According to the docs, it actually relies on table locking for certain operations. What are your sqlalchemy connection strings for the engine ? Have you tried explicitly setting autocommit mode within the query ? Have you tried

Re: [sqlalchemy] Calculate birthdays

2013-08-28 Thread Jonathan Vanasco
On Wednesday, August 28, 2013 12:52:03 PM UTC-4, herzaso wrote: What's wrong with Member.dateofbirth==datetime.today() ? datetime.today() is now -- or August 28, 2013 12:52:03 PM UTC-4 The OP wants a sql operation that matches the Month+Day of Member.dateofbirth to the Month+day of today.

Re: [sqlalchemy] Calculate birthdays

2013-08-28 Thread Jonathan Vanasco
sorry, it looks like the OP did want people born on the current month/day/year combo. you should be able to wrap all the comparisons in a date like this : Member.query.filter( sqlalchemy.func.date(Member.dateofbirth) == '2013-08-27' ).all() Member.query.filter(

[sqlalchemy] Re: Possible bug in select.append_whereclause()?

2013-08-28 Thread Jonathan Vanasco
this looks a little weird to me, because it seems like you're using parts of the ORM (namely sessionmaker) and the rest is the Engine. anyways, you want to address the `table.column`; the results don't exist yet. you can print out any query whenever you'd like below are 2 ways to generate

[sqlalchemy] Re: Modification tracking

2013-08-23 Thread Jonathan Vanasco
I had to do this last week. I posted a recipe in this thread: https://groups.google.com/forum/#!topic/sqlalchemy/Xr1llnf5tzQ tracked objects inherit from RevisionObject, which adds 2 columns to the database: revision_id (INT) revision_history (HSTORE) it also adds 2 methods:

[sqlalchemy] testing for an association proxy (possible bug and patch included)

2013-08-23 Thread Jonathan Vanasco
I have this general structure: class Person: # orm relationships are preceded by (o)ne or (l)ist o_Person2Address_ActiveShipping = sa.orm.relationship( Person2Address, primaryjoin=and_( Person2Address.person_id==Person.id , Person2Address.role_id=='active-shipping' ),

Re: [sqlalchemy] Under what circumstances will a `inspect(myobject).attrs.myattribute.history` be a sequence of more than one item ?

2013-08-15 Thread Jonathan Vanasco
On Thursday, August 15, 2013 12:02:02 AM UTC-4, Michael Bayer wrote: yes it will always be one element for a scalar reference, a collection for collections. the ORM internally treats everything like a collection, kind of another artifact that probably wouldnt have been the case if this API

[sqlalchemy] Under what circumstances will a `inspect(myobject).attrs.myattribute.history` be a sequence of more than one item ?

2013-08-14 Thread Jonathan Vanasco
As previously discussed, i'm using an object's history to log changes to the database within an application. http://docs.sqlalchemy.org/en/rel_0_8/orm/session.html?highlight=history#sqlalchemy.orm.attributes.History Each tuple member is an iterable sequence I'm trying to figure out when I

[sqlalchemy] how to tell which columns are deferred in orm ?

2013-08-14 Thread Jonathan Vanasco
i'm trying to generate a list of non-deffered columns from an object referencing this example: class Book(Base): __tablename__ = 'book' book_id = Column(Integer, primary_key=True) title = Column(String(200), nullable=False) summary = Column(String(2000))

[sqlalchemy] how to access dirty/changed ORM attributes ?

2013-08-12 Thread Jonathan Vanasco
Is there a way to access the changed attributes of an ORM object ? Everything I've dug up refers to the dirty objects in a session, not the attributes of an object. ( I'm trying to automate some revision logging /auditing of sqlalchemy objects ) -- You received this message because you

Re: [sqlalchemy] how to access dirty/changed ORM attributes ?

2013-08-12 Thread Jonathan Vanasco
there's a typo in the docs: bad: attr_state = insp.attr.some_attribute works: attr_state = insp.attrs.some_attribute -- 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

Re: [sqlalchemy] how to access dirty/changed ORM attributes ?

2013-08-12 Thread Jonathan Vanasco
Thanks, Mike! That let me slap together a quick mixin class to store versioned data (of specific columns) in PostgreSQL - class RevisionObject(object): revision_columns = None revision_id = sa.Column(sa.Integer, nullable=False, default=0 ) revision_history = sa.Column(

Re: [sqlalchemy] Code organization with declarative models

2013-08-12 Thread Jonathan Vanasco
Just for a bit of perspective... My SqlAlchemy integration for a project is connected to two distinct applications : - Pyramid -- Web Application - Celery -- Background Processing We're also hoping to get it working on a third - Twisted -- More Background Work There are a lot of moving parts

[sqlalchemy] Re: Association Proxy question ( or other ORM feature )

2013-08-07 Thread Jonathan Vanasco
Thanks! This worked: Document Document2Image_1 = sa.orm.relationship( Document2Image, primaryjoin=and_( Document2Image.document_id==Document.id , Document2Image.image_type_id==1 ) , uselist=False ) document_image_1 = association_proxy('Document2Image_1', 'image') -- You received this

[sqlalchemy] Association Proxy question ( or other ORM feature )

2013-08-06 Thread Jonathan Vanasco
I have three tables that are structured somewhat like this: Document * id * all_images = sa.orm.relationship(Document2Image) Image * id * all_documents = sa.orm.relationship(Document2Image) Document2Image * id * document_id * image_id * image_type_id * document = sa.orm.relationship(Document)

Re: [sqlalchemy] nested transaction syntax is a bit odd ( wishlist? )

2013-07-18 Thread Jonathan Vanasco
Could something be added to the docs then to elaborate on how the context manager works in regards to how things are committed/rolledback ? I just added comments to the existing example ( http://docs.sqlalchemy.org/en/rel_0_8/orm/session.html?highlight=begin_nested#using-savepoint )

[sqlalchemy] nested transaction syntax is a bit odd ( wishlist? )

2013-07-17 Thread Jonathan Vanasco
the nested transaction / savepoint syntax in sqlalchemy appears to be: session = SessionFactory() session.begin() # main tx session.begin_nested() # outer tx session.begin_nested() # inner tx session.rollback() # innter tx session.commit() #

Re: [sqlalchemy] nested transaction syntax is a bit odd ( wishlist? )

2013-07-17 Thread Jonathan Vanasco
On Wednesday, July 17, 2013 7:02:10 PM UTC-4, Michael Bayer wrote: because you can transfer control to some other part of the program that doesn't know what kind of transaction has started; it only knows it needs to call commit() or can rollback() if something goes wrong. It's a simple

Re: [sqlalchemy] SQLAlchemy 0.8.2 released

2013-07-11 Thread Jonathan Vanasco
On a tangent... I just noticed that there are several dozen (if not hundreds) of SqlAlchemy projects on PyPi Perhaps SqlAlchemy is now large enough that it should have it's own classifier ? Something like... Topic :: Database :: Front-Ends :: SqlAlchemy Topic :: Database ::

[sqlalchemy] Re: Dogpile caching: can't pickle function objects

2013-07-11 Thread Jonathan Vanasco
I serialize all my cached data into a dict or json before caching, then unserialize into whatever object i need. -- 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] Re: best practice for SqlAlchemy and webapps ?

2013-07-11 Thread Jonathan Vanasco
Mike, thanks again. I finally found time to integrate your recommendations. https://github.com/jvanasco/pyramid_sqlassist -- 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

[sqlalchemy] is it possible to adapt an object without configuring SqlAlchemy ?

2013-06-30 Thread Jonathan Vanasco
I have a custom object that I use within my application: class Foo(bar): def __init__( self , value=None ): self.value = value def __int__ def __str__ def __cmp__ is there any __baz__ method I can use, that will return a value SqlAlchemy can

[sqlalchemy] Re: is it possible to adapt an object without configuring SqlAlchemy ?

2013-06-30 Thread Jonathan Vanasco
actually, nevermind i just remembered Mike talking about __repr__ last week in his presentation and I tried that. it works. -- 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

Re: [sqlalchemy] best practice for SqlAlchemy and webapps ?

2013-06-21 Thread Jonathan Vanasco
On Friday, June 21, 2013 2:23:54 PM UTC-4, Michael Bayer wrote: fairly recently i wrote up as much as I could come up with on this, which you can see first in the Session FAQ: http://docs.sqlalchemy.org/en/rel_0_8/orm/session.html#session-frequently-asked-questions and then regarding

[sqlalchemy] best practice for SqlAlchemy and webapps ?

2013-06-20 Thread Jonathan Vanasco
Mike blew my mind at the intro to sqlalchemy presentation this week. I learned at least 5 things that I had missed. I still can't believe that the connection itself is basically lazy-loaded and SqlAlchemy doesn't even connect to the DB until you do something. I wrote a bunch of code to

[sqlalchemy] how are foreign relations stored ?

2013-05-16 Thread Jonathan Vanasco
I've been using a utility method 'columns_as_dict' to help store my data in a cache. It works well. A problem I've encountered... i need to access the related data that i've eagerloaded. My current function looks like this def columns_as_dict(self): as_dict = dict(

Re: [sqlalchemy] how are foreign relations stored ?

2013-05-16 Thread Jonathan Vanasco
, at 1:37 PM, Jonathan Vanasco jona...@findmeon.comjavascript: wrote: I've been using a utility method 'columns_as_dict' to help store my data in a cache. It works well. A problem I've encountered... i need to access the related data that i've eagerloaded. My current function looks like

[sqlalchemy] can a SqlAlchemy session be extracted from an object ?

2013-05-02 Thread Jonathan Vanasco
i'm trying to deal with some old code , and need to 'log' a change. in the current code block, I do not have a SqlAlchemy session object - i merely have an ORM object that exists in a given session. is it possible to extract the session object from that ORM object, so I can just add a new ORM

[sqlalchemy] Re: can a SqlAlchemy session be extracted from an object ?

2013-05-02 Thread Jonathan Vanasco
this is WONDERFUL. thanks! On Thursday, May 2, 2013 12:47:25 PM UTC-4, Jonathan Vanasco wrote: i'm trying to deal with some old code , and need to 'log' a change. in the current code block, I do not have a SqlAlchemy session object - i merely have an ORM object that exists in a given

[sqlalchemy] how can i exclude a table on queries ?

2013-04-26 Thread Jonathan Vanasco
Given class Person: id class Topic: id class Person2Topic : id topic_id - fkeys topic(id) person_id - fkeys person(id) class Message: id person_id_author - fkeys person(id) topic_id - fkeys topic(id) I wanted to select by joining the Person2Topic table directly, with a filter query(

Re: [sqlalchemy] how can i exclude a table on queries ?

2013-04-26 Thread Jonathan Vanasco
into this. If i don't find a bug in my code, I'll post a reproducable test-case on github. On Friday, April 26, 2013 7:18:24 PM UTC-4, Michael Bayer wrote: On Apr 26, 2013, at 7:10 PM, Jonathan Vanasco jona...@findmeon.comjavascript: wrote: Given class Person

[sqlalchemy] is this select correct ?

2013-04-22 Thread Jonathan Vanasco
This seems to work. I'm just hoping to run this past the wisdom of other users... SqlAlchemy + PostgreSQL We have a table called `example` which contains versioned fields of a record, attributed to an owner. Goal: assemble a record of the most recent field versions for a given owner class

[sqlalchemy] Re: Automatic created and modified timestamp columns (best practice?!)

2013-03-27 Thread Jonathan Vanasco
FWIW, I've found this sort of stuff to be better done with CURRENT_TIMESTAMP than NOW() , or doing a NOT NULL constraint with no-default and passing in a time from the application. On databases that support it, CURRENT_TIMESTAMP is locked to the transaction and/or statement while NOW() is

[sqlalchemy] Re: SQLAlchemy / Memcache layer

2013-03-26 Thread Jonathan Vanasco
i came up with a novel approach that works, but is sadly not integrated with SqlAlchemy yet. It was more proof of concept and creates a parallel Object Model. It's not good but it's simple and seems to work very well . I'm just going to braindump what I do. It might give you some ideas *

[sqlalchemy] Re: Dialect for Vertica db connectivity ?

2013-03-15 Thread Jonathan Vanasco
doesn't vertica just implement the postgresql sql set one-to-one ? i haven't looked at it in a while, but i remember their sales pitch the trial was all postgres based. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this

[sqlalchemy] Re: CURRENT_TIMESTAMP AT TIME ZONE 'UTC'

2013-03-15 Thread Jonathan Vanasco
much thanks, Audrius i ended up doing the following (last night) before i read this in the morning. 1. s/sqlalchemy\.func\.current_timestamp/sql_now/g 2. def sql_now(): return sqlalchemy.sql.text((CURRENT_TIMESTAMP AT TIME ZONE 'UTC')) i'm working on implementing your more-proper method now. i

[sqlalchemy] Re: Dialect for Vertica db connectivity ?

2013-03-15 Thread Jonathan Vanasco
@Femi - I did a quick search online, but couldn't find any current ( since HP acquisition ) documentation. HOWEVER -- all of the old documentation and QAs that are still online talk about Vertica reimplementing the PostgreSQL syntax and functions. That's in line with what I remembered earlier,

[sqlalchemy] CURRENT_TIMESTAMP AT TIME ZONE 'UTC'

2013-03-14 Thread Jonathan Vanasco
i need to replace my calls to `sqlalchemy.func.current_timestamp()` with something that generates CURRENT_TIMESTAMP AT TIME ZONE 'UTC' anyone have quick advice ? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and

[sqlalchemy] Re: is there a more proper way to chain dynamic or clauses ?

2013-02-22 Thread Jonathan Vanasco
thanks. i was really focused on the query.filter(sa.or_(*ands)) concept. that's what seemed kind of weird to me. -- 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] is there a more proper way to chain dynamic or clauses ?

2013-02-21 Thread Jonathan Vanasco
basd on a bunch of error messages, this example works... criteria = ( ('male',35),('female','35) ) query = session.query( model.Useraccount ) ands = [] for set_ in criteria : ands.append(\ sqlalchemy.sql.expression.and_(\

[sqlalchemy] Re: Is this the right way to do a timestamp filter against CURRENT_TIMESTAMP in postgres ?

2013-02-15 Thread Jonathan Vanasco
ok. is from sqlalchemy.sql import func still the recommended import ? -- 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.

[sqlalchemy] Re: Is this the right way to do a timestamp filter against CURRENT_TIMESTAMP in postgres ?

2013-02-15 Thread Jonathan Vanasco
On Feb 15, 11:17 am, Michael Bayer mike...@zzzcomputing.com wrote: or just from sqlalchemy import func sure thanks. friday is try to pay off technical debt day. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group

[sqlalchemy] Is this the right way to do a timestamp filter against CURRENT_TIMESTAMP in postgres ?

2013-02-14 Thread Jonathan Vanasco
i think this is right... query= dbSession.query( model.Post )\ filter_by( is_published = True )\ filter( model.Post.timestamp_publication = sqlalchemy.sql.expression.current_timestamp() ) this is generating the right sql. i just wanted to make

[sqlalchemy] Re: updating with a Session ?

2013-02-06 Thread Jonathan Vanasco
ah ha! thanks!!! these two approaches worked: results = api.bootstrapped.request.dbSession.writer.execute( model.core.Useraccount.__table__\ .update()\ .where( model.core.Useraccount.id.in_( uids ) )\ .values( migration_a = True )

[sqlalchemy] Re: Tracking changes made to mapped objects

2013-02-05 Thread Jonathan Vanasco
when I do stuff like this on the Web (single and multi-page edits), I build up a dict of 'changes'. When rendering forms, I default to the key in changes or fallback to the sqlalchemy object. when ready to save, I copy over the changes to the object - if there are any changes - and flush. the

[sqlalchemy] Re: how can i use bind parameters with an ilike ?

2013-02-01 Thread Jonathan Vanasco
i forgot to add that this all comes from my irrational fear of Little Bobby Tables ( http://xkcd.com/327/ ) -- 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] how can i use bind parameters with an ilike ?

2013-01-29 Thread Jonathan Vanasco
i need to search something like this: select name from users where name ilike '%jonathan%'; i know i could do this: dbSession.query( models.User )\ .filter( models.User.name.ilike( %%%s%% % 'jonathan' ) but the name is coming from the web, so i want treat it with a bind, like

[sqlalchemy] Re: how can i use bind parameters with an ilike ?

2013-01-29 Thread Jonathan Vanasco
How about using   dbSession.query(models.User).filter(models.User.contains(name)) That generates a LIKE statement , not an ILIKE. I need to case- insensitive match. as a stopgap, i might be able to chain a lower() in there, but something like this should be support. also i'm not so sure

[sqlalchemy] Re: how can i use bind parameters with an ilike ?

2013-01-29 Thread Jonathan Vanasco
On Jan 29, 2:04 pm, Michael Bayer mike...@zzzcomputing.com wrote: ilike is available using column.ilike(some string).   You can turn it into a contains by adding in the appropriate % signs manually.  If you want to do lower() manually, then you can say func.lower(column).contains('some

<    5   6   7   8   9   10   11   >