[sqlalchemy] ResourceClosedError

2011-11-06 Thread AZ (Wei-Ning Huang)
Hi list, I've been getting ResoruceClosedError with MySQL server, which worked fine with SQLite. I'am using Celery queue, and those erros always happen within the celery tasks. @celery.task def do_something(): records = SomeTable.pop_timeout() and for SomeTable.pop_timeout(),

[sqlalchemy] Using update()

2010-06-15 Thread Az
Hi there, Can someone give me an example of using update()? Thanks. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to

[sqlalchemy] Primary key not unique?

2010-06-14 Thread Az
I've got an error that says the primary key is not unique. This shouldn't be possible since my primary keys are unique IDs :S This is only happening after I switched to a physical sqlite3 database from the :memory: one #BEGIN# File Main.py, line 97, in module MCS.addToTable()

[sqlalchemy] Re: Questions about session

2010-06-12 Thread Az
Hi Conor, Many apologies for being pushy but since I'm pretty much in the processing of finishing up my code (due in two days), I wonder if you could just take a look at the last three posts of mine---these constitute the final hurdle and I'll be done :) Cheers, Az On Jun 9, 9:46 pm, Conor

[sqlalchemy] Re: Questions about session

2010-06-10 Thread Az
. Your class definitions... are you defining both table and Class in one go? Would I have to change the way my monteCarloBasic creates instances of SimAllocation? On Jun 9, 9:46 pm, Conor conor.edward.da...@gmail.com wrote: On 06/09/2010 02:45 PM, Az wrote: Expected: students, supervisors

[sqlalchemy] Re: Questions about session

2010-06-10 Thread Az
but now that we have a composite key, what happens to the dictionary? However, the dictionary will just hold information for the current run really. On Jun 10, 6:33 pm, Az azfarul.is...@gmail.com wrote: The pprintout was: {type 'collections.defaultdict': 156,  type 'bool': 2,  type 'float

[sqlalchemy] Re: Questions about session

2010-06-10 Thread Az
) for attr in dir(supervisor): if not attr.startswight('__'): self.attr = deepcopy(self.attr, memo) So this only overrides __deepcopy__ when I call it for a Supervisor and not for any of the other classes right? On Jun 10, 6:56 pm, Az azfarul.is...@gmail.com wrote: So I laid them out

[sqlalchemy] Re: Questions about session

2010-06-09 Thread Az
, given the usefulness of the database. On Jun 9, 4:25 pm, Conor conor.edward.da...@gmail.com wrote: On 06/09/2010 12:44 AM, Az wrote: Traceback (most recent call last):   File Main.py, line 39, in module     MCS.monteCarloBasic(trials)   File //MonteCarloSimulation.py, line 163

[sqlalchemy] Re: Questions about session

2010-06-08 Thread Az
supervisor) won't have to keep running the readData, monteCarloBasic, etc functions just to access the DB (that would be poor indeed!). On Jun 8, 3:07 pm, Conor conor.edward.da...@gmail.com wrote: On 06/07/2010 07:27 PM, Az wrote: By default, deepcopy will make one copy of everything

[sqlalchemy] Re: Questions about session

2010-06-08 Thread Az
, uid, session_id, stud_id, alloc_proj, alloc_proj_rank) VALUES (?, ?, ?, ?, ?, ?)' [1, '1d295f48-7386-11df-8e87-00264a052efc', 1, 5796, 119, 1] Good news: Got the UUID working in a snap. Bad news: See error :( On Jun 9, 4:54 am, Az azfarul.is...@gmail.com wrote: memo = {} copied_students

[sqlalchemy] Re: Questions about session

2010-06-08 Thread Az
) VALUES (?, ?, ?, ?, ?, ?)' [1, '1d295f48-7386-11df-8e87-00264a052efc', 1, 5796, 119, 1] Good news: Got the UUID working in a snap. Bad news: See error :( Note: This happened when I started using 'session.merge(temp_alloc)' instead of 'session.add' On Jun 9, 4:54 am, Az

[sqlalchemy] Re: Questions about session

2010-06-07 Thread Az
is dependent on your GUI toolkit. My GUI toolkit is Tkinter? On Jun 7, 4:01 pm, Conor conor.edward.da...@gmail.com wrote: On 06/06/2010 02:58 PM, Az wrote: Hi Conor, Basically I sat down and made some decisions and changes. I've created an actual copy of the Student class as in I've now got

[sqlalchemy] Re: Questions about session

2010-06-07 Thread Az
(): update_database(result) ui_toolkit.post_callback(runs_in_ui_thread) Thanks for that. Now I know what to search for (message, event queue, callback) :) On Jun 7, 10:50 pm, Conor conor.edward.da...@gmail.com wrote: On 06/07/2010 02:56 PM, Az wrote: Sounds good. Just beware that deepcopy

[sqlalchemy] Re: Questions about session

2010-06-07 Thread Az
): Then best_node = studNew and we find ourselves at #[§§01] But in short, studNew is the same as students which is mapped to Student... I need to get studNew into something that is mapped to StudentDBRecord... is that where I use the function create_db_record comes in? On Jun 8, 1:27 am, Az azfarul.is

[sqlalchemy] Re: Questions about session

2010-06-06 Thread Az
calculations, queries and output. If I can sort these three things out -- this entire project is wrapped up :) Thanks in advance! Az On Jun 6, 4:39 am, Conor conor.edward.da...@gmail.com wrote: On 06/05/2010 08:06 PM, Az wrote: Cheers! Creating a new instance of my mapped class and settings

[sqlalchemy] Re: Questions about session

2010-06-05 Thread Az
run monteCarloBasic(trials) (since it writes to the database). Will it rewrite it every time? Or will it keep appending to it? ++ Az On Jun 4, 10:17 pm, Conor conor.edward.da...@gmail.com wrote: On 06/03/2010 02:33 PM, Az wrote: Firstly, apologies if I'm demanding too much

[sqlalchemy] Re: Questions about session

2010-06-05 Thread Az
, 4:39 am, Conor conor.edward.da...@gmail.com wrote: On 06/05/2010 08:06 PM, Az wrote: Cheers! Creating a new instance of my mapped class and settings, manually. Gotcha. I think this will be an easier solution for me. Nah, I'm not in a web framework. Additional Q: +++ Currently

[sqlalchemy] Re: Questions about session

2010-06-05 Thread Az
use the copy function I created? students_copied = students.copied()? And so if I used this version... my objects won't change (which was why I wanted to use deepcopy) when I make changes to the copied dictionary? Thanks Az On Jun 6, 4:39 am, Conor conor.edward.da...@gmail.com wrote: On 06/05

[sqlalchemy] Re: Questions about session

2010-06-04 Thread Az
it down then) On Jun 3, 7:41 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Jun 3, 2010, at 1:58 PM, Az wrote: Owning session has been closed? Can I still use deepcopy if the session has not been closed? deepcopy has issues because SQLAlchemy places extra information on your objects, i.e

[sqlalchemy] Re: Questions about session

2010-06-03 Thread Az
wrote: On Jun 3, 2010, at 1:24 AM, Az wrote: +++ Questions +++ 1. Is this the correct way to use sessions or am I sort of abusing them? I dont see any poor patterns of use above. 2. When should I close a session? when you no longer need the usage of any of the objects associated

[sqlalchemy] Re: Questions about session

2010-06-03 Thread Az
...@zzzcomputing.com wrote: On Jun 3, 2010, at 1:58 PM, Az wrote: Owning session has been closed? Can I still use deepcopy if the session has not been closed? deepcopy has issues because SQLAlchemy places extra information on your objects, i.e. an _sa_instance_state attribute, that you dont want in your

[sqlalchemy] Questions about session

2010-06-02 Thread Az
))) sqlalchemy.exc.UnboundExecutionError: Instance Project at 0x24c5c50 is not bound to a Session; attribute refresh operation cannot proceed Is this something to do with the way I've been using the sessions? --- Thanks, Az -- You received this message because you are subscribed to the Google

[sqlalchemy] Re: Questions about session

2010-06-02 Thread Az
put two-and-two together right now :( On Jun 3, 6:24 am, Az azfarul.is...@gmail.com wrote: In my code, I am currently adding to the session in various modules (this is the same session since I'm importing it from my most prominent module). Some sample code would be: ## BEGIN CODE 1

[sqlalchemy] Use a foreign key mapping to get data from the other table using Python and SQLAlchemy.

2010-05-26 Thread Az
Basically, I've got these simple classes mapped to tables, using SQLAlchemy. I know they're missing a few items but those aren't essential for highlighting the problem. class Customer(object): def __init__(self, uid, name, email): self.uid = uid self.name =

[sqlalchemy] Re: sqlalchemy 0.5.8 'NoneType' object has no attribute 'get' error

2010-04-12 Thread Az
the scenario and I apologise for that! Az On Apr 9, 4:16 pm, Michael Bayer mike...@zzzcomputing.com wrote: Az wrote: instance_dict(instance)) AttributeError: 'NoneType' object has no attribute 'get' +++ I'm at a loss as to how to resolve this issue, if it is an issue. If more information

[sqlalchemy] Surrogate keys, multiple sessions

2010-04-12 Thread Az
Hi there, I'm just trying to sort out some code implementation utilising SQLAlchemy that should store some output for a Monte-Carlo simulation I'm running. The simulation works thus: I have a dictionary of students, with their preferred projects and a Monte-Carlo simulation that takes said

[sqlalchemy] sqlalchemy 0.5.8 'NoneType' object has no attribute 'get' error

2010-04-09 Thread Az
ask and I will provide it. Kind regards, Az -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com

[sqlalchemy] Re: Creating a Dialect for Amazon SimpleDB

2009-06-04 Thread az
sorry to tune in late, but how different is AmazonDB from googleDB? googleDB seems like a plain non-relational DB like berkeleyDB/btrieve kind of thing. to map a relational and non-relational schemas in same way u need higher level of abstraction - sqlalchemy is only about sql. so i had an

[sqlalchemy] Re: Schema compare utility

2009-05-29 Thread az
On Friday 29 May 2009 20:53:04 Mike Conley wrote: I need to compare database schemas (tables, column names, types, constraints, etc.). Is there anything out there that uses SQLAlchemy metadata to compare database schemas? or should I start working on one? here mine just for a diff:

[sqlalchemy] Re: orm querying: where with a subquery on self

2009-05-12 Thread az
try label the column in q2, say q2.maxgrade, then use that as print s.query(A).filter( A.grade==q2.maxgrade)... On Tuesday 12 May 2009 10:17:11 Max Ischenko wrote: I'm trying to express the following SQL: SELECT * FROM attendances a WHERE grade = (SELECT MAX(grade) FROM attendances WHERE

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread az
u'd better edit a new copy and on save copy all back into original then commit that one, on cancel abandon the new one (but beware of m2m relations if u have them). all else isn't safe/nice IMO. On Wednesday 06 May 2009 17:25:47 Marcin Krol wrote: Hello, I would like to implement typical

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread az
the copy can be a dummy non-db-aware - if that is ok in your case there's yet another option; u can just go all over the original object, and on cancel do a rollback, and restore all changed stuff back by hand (eventualy looking at object-state's history). But this assumes short

[sqlalchemy] Re: Replacing existing object with a changed copy

2009-05-06 Thread az
one2many are the tricky ones - there's no copy as semantics, there's move. Say again? I can't (shallow) copy one-to-many object to another? Or do you mean: I can't copy it to another object, modify it and then copy it back? shallow? if A points to B1, copying B1 to B2 is ok, but u lose

[sqlalchemy] Re: Ambiguous column name in SQL literal query

2009-04-27 Thread az
as the SQl is literal, u have to apply that advice by hand: SELECT crfItem.idCrf, class.name as clsname, attribute.name as attrname ... or something of sorts On Monday 27 April 2009 19:00:24 Mauro wrote: Dear group, I'm having the following issue with Ambiguous column name, in this

[sqlalchemy] Re: Changing Python type associated with temporal datatypes without using custom TypeDecorator?

2009-04-25 Thread az
this direct yourmodels.DateType replacement would work if u had that in some separate file, and all your models imported from that one. But, as there's probably lots of other code and the import DateTime is probably everywhere, i dont think u know which DateTime's to be replaced and which not.

[sqlalchemy] Re: after a week or so of working fine, my app starts experiencing sqlalchemy recursion issues

2009-04-23 Thread az
and what is the query that goes plop? and whereabouts in the code? u can use sys.setrecursionlimit( x) to eventualy move the threshold down and make it die in other occasions too. On Thursday 23 April 2009 18:55:11 Jonathan Vanasco wrote: It starts with the code below, and the last two lines

[sqlalchemy] Re: help with a tricky property mapping

2009-04-14 Thread az
On Tuesday 14 April 2009 16:56:41 Dusty Phillips wrote: On Apr 13, 5:16 pm, a...@svilendobrev.com wrote: mapper(Document, documents, properties={     'document_id': documents.c.id,   # document_id ORM property In the past, I have successfully mapped these properties using synonym,

[sqlalchemy] Re: help with a tricky property mapping

2009-04-14 Thread az
On Tuesday 14 April 2009 17:50:06 Dusty Phillips wrote: On Apr 14, 10:33 am, a...@svilendobrev.com wrote: On Tuesday 14 April 2009 16:56:41 Dusty Phillips wrote: On Apr 13, 5:16 pm, a...@svilendobrev.com wrote: mapper(Document, documents, properties={     'document_id':

[sqlalchemy] Re: Metadata - Inherited Tables, Columns

2009-04-13 Thread az
Is there a way of telling if a table is inherited from another table and which tables it inherits from in the Metadata? inheritance is not really sql notion... so a) look at the mapper.inherits (towards root) and/or mapper.polymorphic_itereator() (towards leafs) b) see if table's primary

[sqlalchemy] Re: Should we separate business logic and ORM mapping classes.

2009-04-13 Thread az
i would bundle them into one... but would probably split on another level. adding items to a user may well be posessions... so it depends. That might well be a model of User with related stuff, which is mapped to database in another way (one2many or Relator object/m2m or whatever), and is

[sqlalchemy] Re: Metadata - Inherited Tables, Columns

2009-04-13 Thread az
On Tuesday 14 April 2009 00:13:10 Jarrod Chesney wrote: I'll look into a) do the mappers pick up foreign key constraints and the polymorphic/inherited details from the metadata when their created or do you have to specify them? both, if ambigious u have to specify manualy. dunno about the

[sqlalchemy] Re: help with a tricky property mapping

2009-04-13 Thread az
mapper(Document, documents, properties={ 'document_id': documents.c.id, # document_id ORM property In the past, I have successfully mapped these properties using synonym, but this time I'm confused because I'm not sure how to define the synonym to a different column name. How do I

[sqlalchemy] Re: Query with outer join and function

2009-04-10 Thread az
that's what i have in bitemporal queries. u need a groupby and subquery/ies. something along subs = select( [C.id.label('cid'), C.d_id.label('did'), func.max(C.value).label('cvalue')] ).group_by( C.id ) giving the max cid/cvalues, and then somehow join Ds with that. D.query(

[sqlalchemy] Re: Complicated query

2009-04-06 Thread az
On Monday 06 April 2009 18:26:06 Marcin Krol wrote: Hello everyone, I've got this query: selectexpr = session.query(Host, Architecture, OS_Kind, OS_version, Virtualization, Project, Reservation) ... selectexpr = selectexpr.filter(or_(Host.earliest_reservation_id == None,

[sqlalchemy] Re: Generating a _BinaryExpression

2009-04-03 Thread az
well... the thing is an AST of a very simple language - python-like expressions (and that is not SQL! e.g. a.b.c == x.y.z whateverelse). u can do with that AST whatever u want - save/load or translate into something else, that is, another grammar. u can build a gui builder/editor over the

[sqlalchemy] Re: Using SQLAlchemy to build sql files (without execution)

2009-04-02 Thread az
for example see copyall.py and copydata.py in http://dbcook.svn.sourceforge.net/viewvc/dbcook/trunk/dbcook/misc/metadata/ On Thursday 02 April 2009 18:24:07 Maxim Khitrov wrote: On Tue, Mar 31, 2009 at 4:20 PM, Yassen Damyanov yassen@gmail.com wrote: On Mar 31, 2009, Maxim Khitrov

[sqlalchemy] Re: Operators in many-to-many relation queries

2009-04-02 Thread az
if the m2m is implicit, u can use it as plain relation for joins etc; except that .has becomes .any and == becomes .contains see class RelComparator in http://dbcook.svn.sourceforge.net/viewvc/dbcook/trunk/dbcook/usage/query.py which i use to make the relation ops look same for m2m and one2m

[sqlalchemy] Re: Generating a _BinaryExpression

2009-04-01 Thread az
i have similar thing, but by keeping an expression in my own terms and rendering into different things, like text, SQL, SA-expresion, etc. u define what is a variable, const, functor, overload all the operators, etc etc; then have a visitor that walks and translates (interprets) it into

[sqlalchemy] Re: Session and pre/post callable methods

2009-04-01 Thread az
u have MapperExtensions, per class, and u have SessionExtension, per session. Both exhibit various events, in different life-span points. i think there are some decorators for declarative... On Wednesday 01 April 2009 19:26:35 Laurent Rahuel wrote: Hi, I'm currently trying to port a Django

[sqlalchemy] Re: Using SQLAlchemy to build sql files (without execution)

2009-03-31 Thread az
you can use echo=True to metadata and/or logging to some extent. there was also some recipe about how to print some query's actual sql without issuing it, see recipes section at the site. but i'm not sure u can really do all you want without having a responding DB-api (which will at some point

[sqlalchemy] Re: Mapping an existing database

2009-03-29 Thread az
see sqlsoup and/or metadata( reflect=True) I'm new to SQLAlchemy. I am trying to use Pylons to expose an existing database in a browser. All the introductory material assumes I am going to create the database from python object definitions, but I want to create the python object definitions

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-03-25 Thread az
ah. when u don't have an explicit spec, the testcases are the real spec. so make sure u really cover all them funny cases (-: i had the default_values problem too, and to solve it i have split the attr.access into two layers: one that sits below SA (as a fake dict), and one thin that sits on

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-03-23 Thread az
let me think about it. as i see it u want to have runtime-invented data-only extensions to some object - or is it data + some algo about it? would the algos be new and reside in the new thing or they're just there and used? imo this should be done via joins ala pyprotocols; inheritance is more

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-03-23 Thread az
On Monday 23 March 2009 23:51:26 Christiaan Putter wrote: Hi, You're quite right, the join was the tricky bit at first. ... The 'dynamically' added classes look something like this: class SMAFields(SecurityFields): sma10 = Float(sqldb=True) def _get_sma10(self):

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-03-22 Thread az
good on yer! one thing that i sorta failed is making a clean set of tests for this. if u aren't too far in the usage, save some major future headaches and do yourself a favour, make such test set. All the things u've tried has to be (simple) testcases - it will be the _spec_ of how the thing

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-03-22 Thread az
On Sunday 22 March 2009 21:17:15 Christiaan Putter wrote: Hi Svilen, Setting up tests is a very good idea, I'll start on some unit testing immediately. Definitely the best way to insure behaviour remains constant as you're working on the implementation, was just to lazy to do so up till

[sqlalchemy] Re: null() and notnull()

2009-03-19 Thread az
def search( self, **kw ): by_where_clause = {} for k,v in kw.items(): by_where_clause[ k ] = v i guess u want to do query.filter_by(**by_where_clause) after that? it's just a syntax sugar over .filter(). so by_where_clause = [] for k,v in kw.items():

[sqlalchemy] Re: interval tree table

2009-03-18 Thread az
On Wednesday 18 March 2009 22:31:37 bard stéphane wrote: is there an easy way to represent an interval tree table in sqlAlchemy Interval Tree is very common way to represent tree. with right, left, level indices, node, leaf (left - right = 1) ? FIY see this thread with various tree

[sqlalchemy] Re: Generating set of AND_ clauses dynamicly

2009-03-06 Thread az
or_( *list_of..) On Friday 06 March 2009 20:30:08 Tomasz Nazar wrote: Hi there, I have small issue and don't know how to solve .. I need to have this kind of query: q = dbsession().query(User). options(eagerload_all('lang_pairs.lang_a'), eagerload_all('lang_pairs.lang_a')).

[sqlalchemy] Re: Modifiable collections on a many-to-many, same table mapping

2009-03-05 Thread az
as i see u have normal mapping for the Connection, and still use it as secondary table; once i did use such (semi-legal?:) thing but the relation was readonly. try not giving secondary* args ? On Thursday 05 March 2009 18:37, Kevin Dangoor wrote: I have a many-to-many mapping that joins

[sqlalchemy] Re: Self Join via Join Table ?

2009-02-25 Thread az
u mean, the Bar is an association table of Foo to Foo? u have to use secondary_table and/or secondary_join in the relation setup. And probably specify remote_side or it may not know which Foo is what. On Wednesday 25 February 2009 03:39:20 Stef wrote: Hello Everyone, First of all, kudos

[sqlalchemy] Re: dynamic relation filtering

2009-02-25 Thread az
thequery().with_polymorphic( list of classes ) ? On Wednesday 25 February 2009 15:43:54 Vladimir Iliev wrote: hi, how can i filter dynamic relation's query to instances of a given class, including the subclasses ? i tried something like

[sqlalchemy] Re: Events Undo/Redo Functionality?

2009-02-24 Thread az
these are two general patterns, observer/listener and undo/redo (command-pattern), which have nothing to do with DB. i dont know about 2) DB-observers which would react on somebody else changing the DB, AFAIK that is possible on certain servers only, but the rest should be done independly on

[sqlalchemy] Re: [sqlalchemy]

2009-02-21 Thread az
what u mean by working? if the object's __init__ is not called when loaded from db (like pickle) - see docs for other hooks. http://www.sqlalchemy.org/docs/05/mappers.html#constructors-and-object-initialization e.g. the @orm.reconstructor decorator On Saturday 21 February 2009 10:28:23

[sqlalchemy] Re: How to write a self 2 self relationship?

2009-02-16 Thread az
put it as text, it will be eval()'uated later On Monday 16 February 2009 10:57:11 一首诗 wrote: I tried to write : #-- -- class User(Base): __tablename__ = 'users' id = Column(Integer, primary_key=True)

[sqlalchemy] Re: How to write a self 2 self relationship?

2009-02-16 Thread az
thats diff. thing, see self-ref. relations http://www.sqlalchemy.org/docs/05/mappers.html#adjacency-list-relationships On Monday 16 February 2009 11:18:59 一首诗 wrote: Like this ? --- - class User(Base):

[sqlalchemy] Re: A question about best practices after the Object Relational Tutorial

2009-02-15 Thread az
I know how to query the database, and to add a new database entry. But I really wanna know where my helper code goes. My idea is that there is a function addCustomer() in the Customer class, but I tried this out and it didnt work. Any suggestions or examples how to proceed? if in the class,

[sqlalchemy] Re: Foreign Key Constraint between seperate metadatas

2009-02-14 Thread az
use one decl-base for all? On Saturday 14 February 2009 18:30:14 dasacc22 wrote: Hi, Say I have two different files that I import that establish tables via declarative_base, so import a, b where there exists a.Group and b.User and then I create my engine engine = create_engine(...)

[sqlalchemy] Re: Foreign Key Constraint between seperate metadatas

2009-02-14 Thread az
put the decl-base only in separate file, and import it in all usages? On Saturday 14 February 2009 19:08:58 dasacc22 wrote: I dont know how I can do that. Right now my a.py and b.py declare their own declarative_base that get subclassed by my table definations. The main goal here is that a is

[sqlalchemy] Re: Foreign Key Constraint between seperate metadatas

2009-02-14 Thread az
look up the group, there was once or twice a discussion on directory structure On Saturday 14 February 2009 19:28:37 dasacc22 wrote: I guess so, I originally gave that idea a pass b/c of the folder structure as the import would have to come from ../../ which means i would have had to modify

[sqlalchemy] Re: Finding the latest matching object from a relationship?

2009-02-13 Thread az
ah, it has to be other way around unit = session.query(Unit).filter(Unit.id==3).first() rec = sess.query( Record).filter( Record.theunit == unit)... where theuint is the backref of Unit.records. see http://www.sqlalchemy.org/docs/05/ormtutorial.html#common-relation-operators or just wait for

[sqlalchemy] Re: Finding the latest matching object from a relationship?

2009-02-13 Thread az
On Friday 13 February 2009 11:02:13 Chris Withers wrote: a...@svilendobrev.com wrote: rec = sess.query( Record).filter( Record.theunit == unit)... Is this as nice as I can get it or is their a slicker solution? this might work too rec = sess.query( Record).filter_by( theunit = unit)...

[sqlalchemy] Re: Reg: Question on SqlAlchemy Speed

2009-02-13 Thread az
On Friday 13 February 2009 11:07:29 koranthala wrote: Hi, I am working on a Python application which does approximately 1000 updates at a time every 3 seconds in a Sqlite File Database using SqlAlchemy. On timing it in a 2GHz machine, I found that it is taking ~1.01 seconds to do the

[sqlalchemy] Re: Reg: Question on SqlAlchemy Speed

2009-02-13 Thread az
The inserts I do is as follows: BEGIN: 2009-02-13 14:34:40,703 INFO sqlalchemy.engine.base.Engine.0x..10 UPDATE data SET status=? WHERE data.index = ? 2009-02-13 14:34:40,703 INFO sqlalchemy.engine.base.Engine.0x..10 ['True', 68762] ... (1000) ... COMMIT

[sqlalchemy] Re: text binding for sql queries

2009-02-13 Thread az
i guess s.execute(stmt, params=dict(codeword=codeword) ) }On Friday 13 February 2009 18:42:26 Max Ischenko wrote: I get an error when I'm trying tu run this: stmt = text(select * from salary_data_new where codeword=:codeword union select * from

[sqlalchemy] Re: single table inheritance : query a subtype and its subtypes

2009-02-13 Thread az
session.query(Child).filter( Child.type != 'childtypenamehere') ? On Friday 13 February 2009 19:05:52 GustaV wrote: Hello! In a configuration looking like this: class Parent: pass class Child(Parent): pass class ChildChild(Child): pass I would like to query the Childs and

[sqlalchemy] Re: single table inheritance : query a subtype and its subtypes

2009-02-13 Thread az
ah sorry, singleinh, ignore my post On Friday 13 February 2009 19:05:52 GustaV wrote: Hello! In a configuration looking like this: class Parent: pass class Child(Parent): pass class ChildChild(Child): pass I would like to query the Childs and all classes that inherits it

[sqlalchemy] Re: Problem with inheritance and cross relations (was: Unable to model cross relations (using ext.declarative))

2009-02-12 Thread az
is this joined inheritance or concrete? IMO if Product inherits Node, they has to have same PK? On Thursday 12 February 2009 23:56:12 Bruce van der Kooij wrote: Many thanks Michael, your instructions were spot-on. In the process of following your instructions I decided to switch from using

[sqlalchemy] Re: Finding the latest matching object from a relationship?

2009-02-12 Thread az
use the relation as a join path, and then whatever filtering/ordering try: unit.join(Unit.records).order_by(Record.date.desc()).first() or unit.join('records').order_by(Record.date.desc()).first() --~--~-~--~~~---~--~~ You received this message because

[sqlalchemy] Re: Pros and cons of flushing subset of session's objects

2009-02-11 Thread az
On Wednesday 11 February 2009 23:07:29 Angri wrote: Michael, I see you dont like the ability to flush only specific objects how about a group of objects? say whole island in the dependency graph? --~--~-~--~~~---~--~~ You received this message because you are

[sqlalchemy] Re: copying data from one DB to another

2009-02-11 Thread az
any2any: see files in http://dbcook.svn.sourceforge.net/viewvc/dbcook/trunk/dbcook/misc/metadata/ copyall, copydata i haven't touched it for a while, see if still works. On Thursday 12 February 2009 01:05:47 Piotr Ozarowski wrote: Hi, Here's what I wrote to create PostgreSQL's data backup in

[sqlalchemy] Re: resultset print keys values

2009-02-10 Thread az
object-query or plain query? - objects are .. whatever class it is; print the i.__dict__ or str(i) or whatever - plain-sql-query ones are RowProxy, they have i.keys() i.items() i.values() On Tuesday 10 February 2009 21:27:09 Lukasz Szybalski wrote: Hello, Could somebody tell me how

[sqlalchemy] Re: Declarative with Enthoughts Traits framework.

2009-02-08 Thread az
afaiknow these traits are like my own static_types, i.e. descriptors holding metadata and applying it to attribute access. i have been combining SA with static_type for more than 2 years now, since SA 3.0. The approach i did in the beginning was to replace the object's __dict__ by something

[sqlalchemy] Re: Need SqlAlchemy Model Advice for a table with many foreign keys.

2009-02-03 Thread az
so u have a member, pointing to member_profile, pointing to all its attributes into separate tables? one way IMO is to map all other 50 tables into simple classes, then have member profile reference each of them, i.e. relation( .. uselist=False). Then, if u need all of them at once, request a

[sqlalchemy] Re: Understanding polymorphism

2009-02-01 Thread az
only the class owner of the identity sets it, internaly. i your case Input has no separate identity, but this does not give u right to set identity manualy. if it had, a=Input( whatver) would set that. or that's how i get it. On Monday 02 February 2009 04:15, MikeCo wrote: I have a single

[sqlalchemy] Re: Adding extra data to column objects

2009-01-31 Thread az
there has been a number of apps announced that do html forms from SA schema - look up the list. afaik Column() takes an 'info=...' dict with whatever stuff u put in it. Same goes for Table() I have been trying to figure out a way to easily create HTML forms and some other stuff from my

[sqlalchemy] Re: Correct way of moving relation

2009-01-29 Thread az
that sess.fulsh() in the middle there... if u move it up/down/out, will behaviour change? e.g. if u print the things in itemB.purchase just _After that flush - is 80 there or not? On Thursday 29 January 2009 20:19:59 Werner F. Bruhin wrote: Michael, I run the following script and initially

[sqlalchemy] Re: Lazy load issue when using declarative_base methodology?

2009-01-28 Thread az
typo - 81087 and 18087? maybe run with echo=True and see what goes on? does the testfile use same engine/.. setup as below? On Wednesday 28 January 2009 19:21:54 Gloria W wrote: This is a strange problem. I'd appreciate any assistance. I have a class set up using the declarative_bass model,

[sqlalchemy] Re: the return type of conn.execute(text())

2009-01-27 Thread az
i have recently stumbled on similar - the rowproxy's __hash__ was missing. so i have to tuple() them before usage. Then there was Mike's question, what should the RowProxy emulate? the tuple of the row, or something else? Today I attempted to serialize the return value of the form result =

[sqlalchemy] Re: and_ and or_ precedence

2009-01-27 Thread az
theoretically - this might make a+b+c+d look like a+(b+(c+d)). Which isn't that bad, except that SA does not level-indent parenthesised expressions, and the sql is going to look like lisp program... but yes, u're right, SA relies on some python precedence and associativity being same as SQL

[sqlalchemy] Re: the return type of conn.execute(text())

2009-01-27 Thread az
On Wednesday 28 January 2009 01:34:30 Michael Bayer wrote: On Jan 27, 2009, at 6:28 PM, a...@svilendobrev.com wrote: i have recently stumbled on similar - the rowproxy's __hash__ was missing. so i have to tuple() them before usage. that doesnt strike me as a similar issue. we should

[sqlalchemy] is there any work around GQL / google-app/datastore ?

2009-01-26 Thread az
g'day i'm asking out of sheer curiosity, although it may turn more serious. is there any known work about linking somehow SQLAlchmey and gogole-stuff? i looked at the google api/lang and they seem somewhat similar to sqlalchemy's (well, like rdf-Alchemy is). i might bite the idea of having

[sqlalchemy] Re: It's possible to access a read-only table(without primarykey) in ORM?

2009-01-22 Thread az
use key=... argument of Column On Friday 23 January 2009 04:52:07 Ikuta wrote: And I got another question now. The Column name has space like below. user = Table('tbl_user', metadata,\ Column('name', VARCHAR(20)),\ Column('phone number', VARCHAR(20))) 1.

[sqlalchemy] Re: Saving the results of a sqlalchemy join using Python

2009-01-20 Thread az
which join are u mentioning? and which result u want to save? the query itself or the objects it returns after execution? q = query(Line).join( Fiber, ...condition ).filter() if ... return q.filter( 123...) else: return q.filter( 456...) building that q is not expensive; saving it is fine

[sqlalchemy] Re: Saving the results of a sqlalchemy join using Python

2009-01-19 Thread az
mmh, cant really grasp what u want to do. what are Line.* attributes? .filter does and(), so this can be simplified: q = query(Line).filter( models.Line.LineDiscarded == LineDiscarded ) if ...: return q.filter( sites...) else: return q.filter( sites...) On Monday 19 January 2009 23:28:55

[sqlalchemy] Re: Testing SQLAlchemy applications without the database

2009-01-18 Thread az
u want to simulate what sqlalchemy is doing? i'd put some layer facading between the app and the sqlalchemy, then replace sqlalchemy with something else. that'll need a) test that assures the two facades behave equivalent, and b) the app tests should not rely on any partcular

[sqlalchemy] Re: Selecting from a self-referential mapper: recursive joins?

2009-01-17 Thread az
u can look at my posts on the topic and all related too (-:) search for recursive/recursion/graph/sets in short: - storage: - store graph in pure form (nodes/edges only) - easy to maintain/update, very difficult to query - store some preprocessed (cached) denormalized form (all paths

[sqlalchemy] Re: Migrating objects across sessions

2009-01-17 Thread az
read various threads about copy/deep-copy. in any case u'll have to do the hierarchy-copying yourself - even if moving one object (alone) from session to session succeeds somehow. On Saturday 17 January 2009 14:47:41 Darren Govoni wrote: After some further experimenting with this, it seems I

[sqlalchemy] Re: Migrating objects across sessions

2009-01-17 Thread az
Yes, i'd like to do that, but because of the code injection seems to carry state from the old session, the new session has trouble with even the copy. then, separate the issues: a) make a working deep copy within same session (this is not at all trivial, except for very simple schemas) b)

[sqlalchemy] Re: mysql udfs

2009-01-15 Thread az
try func.yourfuncname(..) ? On Thursday 15 January 2009 03:18:51 clb wrote: Hi, I have been scouring the sqlalchemy 0.5 documentation and can't seem to find information on how to execute UDFs. I am dealing with the following scenario: 1. I create a UDF (for example, get_fav_id, which

  1   2   3   4   >