[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(), th

[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+unsub

[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 MCS.addToTable() File "/X

[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

[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 wrote: > So I

[sqlalchemy] Re: Questions about "session"

2010-06-10 Thread Az
be a NoneType (realised that right now!) Additionally, I'd like to maintain the ForeignKey relationship with the StudentDRRecord table for pulling in info about a student. Also, I've not got rid of ident because I don't know how else to map SimAllocation to a dictionary as we

[sqlalchemy] Re: Questions about "session"

2010-06-10 Thread Az
['trial.run_id', 'trial.id']), > {}) > > run_id = Column(Integer) > trial_id = Column(Integer) > stud_id = Column(Integer) > > trial = relationship('Trial', back_populates='sim_allocs') Ah tru

[sqlalchemy] Re: Questions about "session"

2010-06-09 Thread Az
d the date-time to a text file. My supervisor would have to copy paste that into a GUI text field or the command line but it's not that much of a hassle, given the usefulness of the database. On Jun 9, 4:25 pm, Conor wrote: > On 06/09/2010 12:44 AM, Az wrote: > > > > > Tra

[sqlalchemy] Re: Questions about "session"

2010-06-08 Thread Az
0009, 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 wrote: On Jun 9, 4:54 am, Az wrote: > > memo = {} > > copi

[sqlalchemy] Re: Questions about "session"

2010-06-08 Thread Az
(statement, parameters, e, connection_invalidated=is_disconnect) sqlalchemy.exc.IntegrityError: (IntegrityError) columns uid, session_id, stud_id are not unique u'INSERT INTO sim_alloc (ident, uid, session_id, stud_id, alloc_proj, alloc_proj_rank) VALUES (?, ?, ?, ?, ?, ?)' [

[sqlalchemy] Re: Questions about "session"

2010-06-08 Thread Az
do I access the DB data then? Would I have to write some separate functions that allow me to access the data without using (for example) 'session.query(Student)...`? This way the user (i.e. my supervisor) won't have to keep running the readData, monteCarloBasic, etc functions just to

[sqlalchemy] Re: Questions about "session"

2010-06-07 Thread Az
on): 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 a

[sqlalchemy] Re: Questions about "session"

2010-06-07 Thread Az
> queue to which you can post messages from any thread. So you could do > something like: > > result = monteCarloBasic(...) > > def runs_in_ui_thread(): > update_database(result) > > ui_toolkit.post_callback(runs_in_ui_thread) Thanks for that. Now I know what to sear

[sqlalchemy] Re: Questions about "session"

2010-06-07 Thread Az
(either because they are unmapped or are transient > > <http://www.sqlalchemy.org/docs/reference/orm/sessions.html#sqlalchemy...> > instances), which the UI thread uses to update the database. How > you pass data from worker threads to the UI thread is dependent on

[sqlalchemy] Re: Questions about "session"

2010-06-06 Thread Az
data to persist between threads (and after I've closed my program) so I can use them for all manner of useful 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 wrote: > On 06

[sqlalchemy] Re: Questions about "session"

2010-06-05 Thread Az
udents[ee_id] = Student(ee_id, name...) So BEFORE I was just doing students_copied = copy.copy(students) How would I 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

[sqlalchemy] Re: Questions about "session"

2010-06-05 Thread Az
was the only thing I can think of since student ID's will repeat after every individual trial is done. Oh also: a BIG thank you for taking the time to help me out! I'm almost at my deadline :) On Jun 6, 4:39 am, Conor wrote: > On 06/05/2010 08:06 PM, Az wrote: > > > > > C

[sqlalchemy] Re: Questions about "session"

2010-06-05 Thread Az
27;ve got my understanding correct). Additionally, when I save to a physical database file, what happens everytime I 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 wrote: > On 06/

[sqlalchemy] Re: Questions about "session"

2010-06-04 Thread Az
ys of closing a session besides that? (If the answer is "Plenty", don't worry about it... I'll try to track it down then) On Jun 3, 7:41 pm, Michael Bayer wrote: > On Jun 3, 2010, at 1:58 PM, Az wrote: > > > "Owning session has been closed"? Can

[sqlalchemy] Re: Questions about "session"

2010-06-03 Thread Az
would work? >> How can I stop it from closing the >> sessions? > nothing in SQLA closes sessions. Your program is doing that. I'm not issuing a session.close() anywhere (I checked). Are there any other ways of closing a session besides that? (If the answer is "Plenty&q

[sqlalchemy] Re: Questions about "session"

2010-06-03 Thread Az
lush error? I've gone back to using just copy.copy(some_dictionary) just >>after<< I read into my dictionaries and >>before<< I start doing stuff like monteCarloSimulation (above) and addToTable (above). Even if I stick the copy.copy() after addToTable(), it still manages to

[sqlalchemy] Re: Questions about "session"

2010-06-03 Thread Az
57 pm, Michael Bayer 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

[sqlalchemy] Re: Questions about "session"

2010-06-02 Thread Az
session work but my head just can't put two-and-two together right now :( On Jun 3, 6:24 am, Az 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 modu

[sqlalchemy] Questions about "session"

2010-06-02 Thread Az
chemy-0.5.8-py2.6.egg/sqlalchemy/orm/ mapper.py", line 1864, in _load_scalar_attributes "attribute refresh operation cannot proceed" % (state_str(state))) sqlalchemy.exc.UnboundExecutionError: Instance is not bound to a Session; attribute refresh operation cannot proceed Is this

[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 = name

[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 dicti

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

2010-04-12 Thread Az
scenario and I apologise for that! Az On Apr 9, 4:16 pm, "Michael Bayer" wrote: > Az wrote: > > instance_dict(instance)) > > AttributeError: 'NoneType' object has no attribute 'get' > > +++ > > > I'm at a loss as to how to

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

2010-04-09 Thread Az
'm at a loss as to how to resolve this issue, if it is an issue. If more information is required, please 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 ema

[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 ide

[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: http:/

[sqlalchemy] Re: SQLAlchemy 0.5.4p1 Released

2009-05-18 Thread az
hi i run today my tests just out of curiosity, so dont worry if not a time for it. here one more session.merge thing that has been working before... (now on trunk r5970) File "other/expression.py", line 436, in p = session.merge(p) File "sqlalchemy/orm/session.py", line 1162, in merge

[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 WH

[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, b

[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 editing/single

[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: 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 si

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

2009-04-24 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 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_

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

[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: 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: 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 sh

[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: 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( ...).filte

[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, and

[sqlalchemy] Re: Building a query with "if(type = "purchase", value, 0)"

2009-04-05 Thread az
try with func.if_() On Sunday 05 April 2009 21:19:29 Wouter van Vliet wrote: > Hi Folks, > > After an hour or so of browsing the net and documentations, getting > increasingly frustrated and being about to just - nah, I didn't > really consider throwing sqlalchemy out of my project. But still

[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 t

[sqlalchemy] Re: Insertion issues

2009-04-02 Thread az
whateverfunction( **{key1:value1,...}) On Thursday 02 April 2009 10:55:20 Tanmoy wrote: > Hi.. > I am trying to create a database where i am trying to keep > column names as 10:00 and 10:05. The problem is when i am trying to > insert values like users.insert().values(..,10:05='1200')

[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: 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 wrote: > > On Mar 31, 2009, Maxim Khitrov wrote: > >> I should a

[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: 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 whateve

[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 r

[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 definitio

[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 t

[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(se

[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-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 ti

[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 wo

[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: is_backref & circular cloning

2009-03-19 Thread az
this clone stuff comes over and over and over... i have similar .copy() in dbcook unfinished.. 1) see prop.direction as one of (ONETOMANY, MANYTOONE, MANYTOMANY) to figure  the "direction" of the relation. why does it matter which side you're on? as long as u copy one side only.. as of 2) .. d

[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 rerpesen

[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 again

[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 > > part.documents.filter(Part.documents.of_type

[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: Events & Undo/Redo Functionality?

2009-02-24 Thread az
offended? not at all. i just dont think that u can get away with less (as amount and as trickiness) code by doing these within SA (e.g. attaching into mapper-, attribute- or session- extensions). but let's see what others will say about it. sorry i can't help. ciao svil On Tuesday 24 February

[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 hi

[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 lau

[sqlalchemy] Re: puzzling setup with ForeignKey

2009-02-19 Thread az
if u make it the same way as the other ticket_status... key, would it work? On Thursday 19 February 2009 13:57:07 Alessandro Dentella wrote: > Hi, > > in a working setup I added a ForeignKey to table > 'cliente_cliente' as follows (client_id): > > class Project(Base): > __tablename__ = "t

[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: 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=Tr

[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 cla

[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 modif

[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

[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: 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 in

[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

[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

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

[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 th

[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: 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 Mi

[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: 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: 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

[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 ar

[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 c

[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 sm

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

2009-02-04 Thread az
it cannot find Member class. do u have two or more declarative_bases? u should have just one. and i would put all these as direct class references instead of "strings". On Wednesday 04 February 2009 19:02:49 Gloria W wrote: > Thanks for this response. I do need all of the data available at > on

[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 ta

[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 sc

[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 initiall

[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, s

[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 shoul

[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 on

[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] 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 db

  1   2   3   4   5   >