On Friday 27 July 2007 19:48:51 Jonathan Ellis wrote:
I'd want to make sure this didn't hurt performance first. (Seems
innocuous enough, but if it's in any sort of inner loop the extra
hash lookup might be noticeable.)
if lookup is made once in the start of function, should be okay.
which
btw around probing dbcook on 0.4, i got some sort of statistical
idea of what is used often, some in a frightening repeatable
pattern:
from sqlalchemy import *
db = create_engine('url')
meta = MetaData(db)
and just then all else follows... in 90% of my files.
i can make some
yeah look, this is how it works. your table has x, y, and z.
you set up a mapper. x, y and z all become ColumnPropertys on
your mapper, without you doing anything, i.e. no properties dict.
if you set up a properties dict, columns which you map
explicitly will override the normal x,
noone wanting to try autoload'ing nor metadatadiff? i am surprised..
Christophe, u can at least try how much autoload.py works like your
autocode2 - i got lost with 'schema' vs 'dbname' - and/or add mysql
support (;-)
http://dbcook.svn.sourceforge.net/viewvc/*checkout*/dbcook/trunk/autoload.py
On Wednesday 25 July 2007 19:34:50 Marco Mariani wrote:
Anton V. Belyaev ha scritto:
again, im not opposed to this feature and ill patch in an
adequate (and fully unit-tested) implementation. but have you
actually ever *had* this problem? or is it just hypothetical ?
For example, a
here some theory on comparing data trees, in order to produce the
changeset edit scripts.
http://www.pri.univie.ac.at/Publications/2005/Eder_DAWAK2005_A_Tree_Comparison_Approach_to_Detect.pdf
of course full automation is not possible and not needed - but why not
do maximum effect/help with
The trouble is (and, sorry, this is getting beyond SQLAlchemy-
specific), that leaves me without any good ideas for how to
distinguish sequence types (lists, tuples, and user-defined objects
resembling them) from mappings (dicts).
i usualy differ between sequences/generators and dicts by if
On Tuesday 24 July 2007 23:29:52 Rick Morrison wrote:
The list is useful only for a hacker on the MSSQL module, not for
general users, but FWIW, I've added it to
http://www.sqlalchemy.org/trac/wiki/DatabaseNotes
thanks
I generally try to respond directly to help encourage anyone
willing to
this is the relative vs absolute import conflict, see python 2.5 news
and the PEP about it. i'm not sure if last py2.5 really does all
that, it didnt work here.
The code u have, imports the module via different paths - some
relative, e.g. current dir, and other absolute - e.g. via pythonpath,
In other words, should I first attempt to
__import__('vor.'+modname) in runJob() ?
see the python reference about how to use __import__ over hierarchical
paths, or use this instead
def import_fullname( name):
m = __import__( name)
subnames = name.split('.')[1:]
for k in subnames:
this ain't SA issue, but if u want a solution, u have to provide more
data, and do some prints here-there.
When a scheduled job is run, its specified module is loaded using
__import__ . This works fine unless the loaded module has an
'import model' in it. If so, I get this:
Traceback (most
g'day.
This is dbcook, a framework to cook databases from recipes, written
as python declarations. Eventually the result may be edible (;-)
(previous pre-names: sawrap, o2rm... it's about 10 months old now)
If u're interested, have a look, dbcook/usage/example1.py might be a
start. The
g'day.
This is dbcook, a framework to cook databases from recipes, written
as python declarations. Eventually the result may be edible (;-)
(previous pre-names: sawrap, o2rm... it's about 10 months old now)
If u're interested, have a look, dbcook/usage/example1.py might be a
start. The
if u can make the a query( primary_mapper, select_table)
somehow possible... i won't need separate NPs. Note this
selecttable is not additional .select() off the query, it IS
the starting query(), e.g. thepolymorphic union in a big case
and
base-class-only in a small case.
thought it might. In my little MCV world, it's part
of M, not C or V and I wanted to keep it that way as much as
possible. It still is, just not in SA.
i have similar thing into the M/odel, but it is pre_save(), not
after_load(). So it's easier, and done by the sa-managing wrapper.
Though
not an option. Neither is renaming DB columns.
i was talking of renaming the column-names of SA/app, not those in the
db.
see key arg of Column():
key
Defaults to None: an optional *alias name* for this column.
The column will then be identified everywhere in an
- Using polymorphic, joined-table inheritance ? Forget about
polymorphic_union(), just join all the tables together using
outerjoin(). In 0.4, even the select_table argument becomes
optional.
i am not sure if i got this right (a month already). A-B-C works, yes.
But just explain to
- Using polymorphic, joined-table inheritance ? Forget
about polymorphic_union(), just join all the tables together
using outerjoin(). In 0.4, even the select_table argument
becomes optional.
i am not sure if i got this right (a month already). A-B-C works,
yes. But just explain
i played a bit with your thing...
how do u expect the id column to appear in the Employee actualy?
do u expect to get the base person' one, or the child one? or both?
looking from the child, yes, the child one will obscure the parent
one, but from the parent.. u'll never get the child one.
i
On Wednesday 11 July 2007 21:49:48 Mike Orr wrote:
On 7/11/07, Jose Galvez [EMAIL PROTECTED] wrote:
Dear Mike,
I've read the doc string in the new sacontext and was just
wondering why for add_engine_from_config do you have to
explicitly pass None for the default connection? it would make
Lets say there are Employee, Engineer, Manager, etc whole tree, with
Employee in the root; all levels do have instances and its
polymorphical multitable inheritance.
Let's the Employee has attribute age - number, and manager - pointing
to some other Employee.
how to get all Employees which
anyway, i copied prop.get_join and removed all polymorphic stuff +
cache, and now such expressions work.
Gaetan, u still interested in this db-cooker of mine?
i think i have something to show...
--~--~-~--~~~---~--~~
You received this message because you are
the new interface is super clean, consistent and flexible. and
with that, we are able to add more features onto it. a cluttered
interface doesn't accept new functionalities as easily.
There was one more difference betwen filter* and select* - first is
just building a query, 2nd is building
SAContext is a little top-level organizer for engines, metadatas,
and a session context. It was written for Pylons due to the
confusion people were having setting up their models, but the
SAContext class itself can be used in any SQLAlchemy application.
it's all okay. i just thought that if it is a Context, u should have
some destructors - as u call many constructors. otherwise it is not
reentrant - or at least repeatable.
But if the idea is that this context will always be one-and-only,
lives forever, and all db-stuff will happen within
On Thursday 28 June 2007 17:50:17 Michael Bayer wrote:
On Jun 28, 2007, at 4:12 AM, svilen wrote:
i have some opinion/wishes around this one too.
i have a complete validating/verificating descriptors for all my
attributes (plus no other attributes are allowed on my
model-related classes
u may need an explicit intermediate association object, see the docs
about many to many relations.
Instead of directly getting the children, u'll get the associations
via which u can get the children, or whatever attributes of the link.
Then if u want a direct children-list, u can make some
thanks a lot, that cleared some mist.
btw u can make a entry on the FAQ from this... e.g. lifetimes and
usage patterns - or similar.
The other rule inferred from above problem is
b) objects lifetime should be shorter than mappers (ORM); else
one needs to delete o._instance_key and
sorry, http://linuxteam.sistechnology.com/o2rm/o2rm0224.tar.bz2
Thank you but when I try downloading
http://www.sistechnology.com/o2rm/o2rm0224.tar.bz2, I get a 404 not
found :-(
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the
I'm working in a GUI project and use the SQLAlchemy for ORM.
Can anyone tell me how to catch a attribute changed event in
SQLAlchemy so that application can update the UI automaticly.
depending on how/when exactly are u going to check for attr-change, u
can look for 'dirtyness' of the
are u using assign_mapper?
use plain mappers to have minimal impact, u will still get plenty of
new descriptors + __init__ replaced
On Wednesday 13 June 2007 07:35:16 Ian Charnas wrote:
Inspired by the SQLAlchemy docs, I'm writing a documentation
generator in python using a combination of
what version u use?
i tried your thing, that is
$ python -i zz.py
s = create_session()
j = s.query(Job)[0] #get first
del j.files[0]
s.flush()
and seems to work
before:
for a in s.query(Job): print a.name, a.files
...
Job 1 [__main__.File object at 0xb78ec72c, __main__.File object at
Some of my coworkers had the same needs of Gaetan... And while I
understand your solution, I figure out if SA could have it natively
(detecting the presence of a dictionary)...
Somethink like:
query.get(dict(columnB='foo', columnA='bar')
Lazy programmers are the best ones... :)
why
well, if u dont want to write the same thing over and over, write one
wrapping function, and publish it here.
e.g. something like (pseudocode):
def _get_pk_ordered( klas):
table = orm.mapper.registry(klas).mapped_table #or select_table
return whatever-list-of-columns
def
On the second point, the complexity of the full cascade recursion
with orphan detection makes sense. I suppose I'm interested in any
input from anyone else as to how they are handling these sorts of
operations in many-to-many cases with changing associations.
As i need a history
the legal way is the association_proxy and family.
here another shorter ... a hack:
i did have similar need - obj.somerelation.append( left=.., right=..),
so i did monkeypatch the InstrumentedList's append to use the item
returned from collection's append -
def append( self, *args,
I know ive put many folks through the wringer dealing with this
function, in order to get their inherited mappers to load instances
polymorphically. It seems like we probably dont need it for the
most common case, which is that you are using only joined-table
inheritance from a single
hmm, actualy, in such
select.append_whereclause().order_by().group_by().whatever1
().whatever2()...
What is the point of anything except the very first funccall to be
generative? the direct results are thrown away, and the copies are
used - whyfore?
(i guess this applies to query() as
what about adding a docopy=True (or dont_copy=False) to all methods
that could be both copy_generative and modify-in-place?
via some generic self=self.copy_if_required() func?
Then one can choose at which point to split+copy
let me summarize things that im thinking we do:
- we want to go
what about adding a docopy=True (or dont_copy=False) to all
methods that could be both copy_generative and modify-in-place?
via some generic self=self.copy_if_required() func?
Then one can choose at which point to split+copy
well if you have switches that are dynamically modifying the
On Friday 01 June 2007 21:38:15 Michael Bayer wrote:
On Jun 1, 2007, at 1:24 PM, Michael Bayer wrote:
and we can even bring back a modified version auto-descend in
that case:
query(A).filter_by(C, lala=5)
since above its not ambiguous.
actually, scratch that. C can be related to
maybe keep only _one_ method which gives a fullblown Query() object,
which then can be used as one wish?
On Friday 01 June 2007 06:47:01 Michael Bayer wrote:
heres the question. Query gets 10 new methods one day. do we then
add 10 methods to assign_mapper() ? must the user class be a total
I'm not sure how querying should work, I guess doing a get by
primary key should automatically use the correct database. What
about other searches? Do these consult all the databases and merge
the results? And what about joins?
i would expect so. and a way to say .search(all) or search(
add on top of this versioning/bitemporalism and things get
tough...
big words again...hold on...zero google hits for
'bitemporalism'...OK i guess that means two things happening at
once
I think he means the distinction between actual time and record
time of temporal objects as
On Monday 28 May 2007 23:43:37 Michael Bayer wrote:
On May 28, 2007, at 3:33 AM, [EMAIL PROTECTED] wrote:
To avoid trouble if erasing fails, i may also add some sort of
state-flag is_temporary to all those records, so they can be
visible within the transaction (flag is True), but not
I've got a meeting coming up with a small team from a commercial DB
vendor that's interested in extending their support into the Python
community (yea!). Unfortunately, their analysis up until this
point has left them with the impression that supporting the django
ORM is the first priority,
On Friday 20 April 2007 16:59:55 Michael Bayer wrote:
On Apr 20, 2007, at 5:00 AM, Ram Yalamanchili wrote:
I have this piece of code which I came across accidentally:
page = 0
limit = '1'
# note that one of the above values is a string, and the other a
0 data =
u could workaround by adding another python property to Pet:
class Pet:
directspecies = property( lambda self: self.species.species, ...)
svil
On Sunday 15 April 2007 02:51:07 Brendan Arnold wrote:
Hi there,
Lets say I have a table with a foreign key that relates to another
table with and
#476 - forget the visitor stuff; i use the simpler code that is in the
text of 02/15/07 09:59:22 changed by svil comment, for some 2
months now, and all is ok.
i've added the patch/code to that ticket as well as to #474/475.
On Friday 13 April 2007 23:17:37 Ants Aasma wrote:
On Apr 13, 10:16
seems this is the month of the many2many relations ;-)
more on the theme: many2many
i have a association of 3 tables, A,B,C.
one of them (C) may not be present in all assoc_items.
So that column has nullable=True.
when you say, association of 3 tables, A,B, C, do you mean, there
On Tuesday 27 March 2007 17:18:04 Michael Bayer wrote:
On Mar 27, 2007, at 3:53 AM, [EMAIL PROTECTED] wrote:
Lets say u have 5 leaf types in 4-5 levels of the hierarchy tree,
say that makes 10 tables total.
say E object is a leaf and comes from A.join(B).join(C).join(E) -
so E is split
On Tuesday 27 March 2007 18:12:37 Chen Houwu wrote:
from the docstring in
class Column:
def __init__()
name
The name of this column. This should be the identical name as
it appears, or will appear, in the database.
key
Defaults to None: an optional alias name
try Column()'s parameters quote=.. and key=..,
doc/docstrings.html#docstrings_sqlalchemy.schema_Column
and/or mapper's explicit column-naming:
doc/adv_datamapping.html#advdatamapping_properties_colname
On Sunday 25 March 2007 08:04:02 Chen Houwu wrote:
from the sqlalchemy documentation,
I
On Saturday 24 March 2007 21:35:19 Michael Bayer wrote:
On Mar 24, 2007, at 4:38 PM, [EMAIL PROTECTED] wrote:
i would also say its slightly better in the case of joined table
inheritance to *not* query for the type column as well since it
can add weight to the query.
hmm, probably. how
isn't polymorphic_union( { 'a': select..., 'b': select... }, 'kind' )
working in your case?
On Wednesday 21 March 2007 21:37:47 Toshio Kuratomi wrote:
Hi guys.
I'm using sqlalchemy with TurboGears. The code for my project is
GPL, so if you need access to more source just let me know:
I
On Tuesday 20 March 2007 07:47:53 Benno Rice wrote:
Hi,
I'm wondering if it would be possible to have a situation where
transactions coming in from the ORM system could be sent to
multiple database servers at once.
If I were to look into adding this, where would be the best place
to
because
a) SQL-standard says names are caseless - Fun anf fUn are same thing
b) most SQLs allow mixed case but require it in quotes, and some are
_very_ picky about it (postgres)
c) readability - lowercase names differs well from uppercase reserved
words
On Thursday 15 March 2007 06:26:03
What do you think?
Hey list, are you confused by the current system ? Please let me
know.
the only change I would favor here would be to merge connect into
MetaData, BoundMetaData and DynamicMetaData stay around for
backwards compat for probably forever, and perhaps we add another
hallo.
AFAIsee rev 2362 fixes the lazy-load for polymorphic properties.
but is seems to introduce another problem.. or maybe uncover it.
table-inheritance, A-B-C-D, and A has reference to B.
2361: lazy-ref is loaded wrong
...
File /home/az/src/hor-trunk/db/sawrap/tests/sa_gentestbase.py,
try putting primaryjoin=... inside the backref()
I've been trying to recreate the self referential 'parent/child'
mapper tutorial:
http://www.sqlalchemy.org/docs/adv_datamapping.myt#advdatamapping_s
elfreferential
I keep getting the following error:
Error determining primary and/or
final, ok for indirect recursion too .
##
import sqlalchemy
def join_via( keys, mapper):
'''Query.join_via, input root mapper, return last mapper/table;
alias and link properly recursive /self-referential joins
'''
clause = None
c = None
self_table = None
i'm not sure if i understand what u want, but u can do nested join(
prev_join, table_next). Also see the full spec of select(
columns_list, whereclause, from_obj_list, order_by, group_by, )
something like
table_a.join(table_b).join(c).join(d).select([columns_here])
for the implicit
oh right, old_init(), sorry, didnt read the first post carefully.
i almost think the answer here might be to not even create the
modified __init__()/old_init() method in the general case...if
youre calling session.save(someobject) its not really needed.
but for now...maybe
I'm trying to create a mapped object where I don't know what the
exact constructor arguments of the object might be. I was trying
to use the inspect module to get the right arguments, but it looks
like the mapper is redefining the original class __init__. Any
thoughts as to how I might
There is more;
to have really independent tests u have to destroy all SA caches and
mappers etc.
metadata.drop_all()
clear_mappers()
db.dispose()
and always let ALL sessions etc fall out of scope.
Make sure u do not store exception contexts, nor any persistent
objects between the tests.
yeah im no mathematician but i dont think you can use just part of
a theory thats designed for flow diagrams with some totally
different kind of diagram.
well, relational algebra, or graph theory is just that, and can be
used for wbatever one finds applicable. diff Application aspects may
noting that, i have
spent almost no time at all on supporting concrete patterns at
this point (also, nobody has really complained).
no worries, i've doing now a cut over proper graph, built in
similar way as the one unitofwork's topology is using,
scratch that, instead i propagated a
- using value.lower() == value instead of value.islower()
ha
x = 27
x.islower()
False
x.lower() == x
True
breaks a lot of tests too
okay, forget that. Here an example OrderedSet over set; that seems to
give a bigger speedup than anything else, and without touching
anything.
another things i noted:
- using value.lower() == value instead of value.islower()
- ansisql.py:
in _requires_quotes():
this
bool(len([x for x in str(value)
if x not in self._legal_characters()]))
should be same as
bool( s.translate( 256*' ',
Here one more random pick, of same errors.
There are only these 3 kinds of errors in the whole run, lazy+eager,
about 9800 cases, and about 4700 errors (also attached):
- some B being loaded as C /4500
- sqlError- no such column pu_B.linkB_id /224
- circularDep /42
The first one plays tricks,
here next portion - 3 kinds, one case per kind.
all tests pass with rev 2267 of that branch. try that rev
specifically, since i want to take whats there and do another pass.
im trying to get it so that the entire science of parent table,
child table, polymorphic selectables, primary join -
here next portion - 3 kinds, one case per kind.
hm.hmmm. on sqlite they were 3 failing - now only 2;
on postgres all 3 fail...
The cirlcular dep one - is there because i cannot get where the
circ-dep is. The post-updates are invented by the mincut algo, and i
don't see why such configuration
So, ive been working on this crapola pretty much all day...
WAW!
hey, don't overdose...
(YOURE WELCOME) ...
Hhmm. i don't believe in virtual beers, so maybe, treat you with this?
http://www.giovannisample.com/media/mondo/Mondovision640.zip
and the latest is in a branch
all tests pass with rev 2267 of that branch. try that rev
specifically, since i want to take whats there and do another pass.
im trying to get it so that the entire science of parent table,
child table, polymorphic selectables, primary join - polymorphic
joins - determine direction/lazy
Employee points to Dept and Dept points to Director; Director
inherits Employee. no other references.
thats not the test case im talking about, you gave me just A and
B with B point to A (which is A pointing to A).
that right, i found another case giving the same error, and thought it
Mike,
On a side note, do u have any ideas about supporting stored procedures
in some way? Be it just knowing about them and maybe calling them, or
on the other end, generating them?
IMO they are _some_ way to hide some of those session.queries...
Although i'm just extrapolating my own vision
Can we invent some practical rule about what cannot (or should not)
be lazy?
sorry, what cannot (or should not) be _eager_
a) self-reference and inheritance between pointing and pointed, in
any direction
b) anything else ??
--~--~-~--~~~---~--~~
You
i have added a switch for lazy on/off to that 115-case full
combination test for A-B inheritance and relations.
For lazy=True all is ok.
For lazy=False, i am setting lazy=False only for those relations which
refer to klas not a subklas to the main one.
The result is 8 cases fail, all of same
limited to non_primary mapper ? creating relationships with
non_primary mapper is a bad idea. the foreignkey error really
means, cant find a foreignkey *that I recognize as part of the
parent or child tables*.
hmmm.
u mean, making the non-primary mapper equivalent (relation-wise) to
the
okay, let me release something too.
http://linuxteam.sistechnology.com/o2rm/sawrap0124.tar.bz2
i'm still looking for a name...
Basic idea of this SAwrapper is to be 3rd-level declarative translator
(SA has 2, non-declarative: orm-sqlpy, sqlpy-sql-dialect) and hide
the SA's specifics, i.e.
hi.
Lets have a Person having .address having .country having .name.
How would give-me-persons-which-live-in France be expressed in SA
(sorry for my SQL ignorance)?
e.g. all-persons-for-which person.address.country.name == 'France'
thanks
svil
Lets have a Person having .address having .country having .name.
How would give-me-persons-which-live-in France be expressed in
SA (sorry for my SQL ignorance)?
e.g. all-persons-for-which person.address.country.name ==
'France'
the concretes fail because concrete is not a completed feature at
the momentim not even looking at those yet.
the session.clear() should be done in all cases, the tests are
completely pointless without it since you are just re-displaying
the relationships you already constructed. so i
creating non-dynamic forms of the failing tests, like 2 or 3
of them (i.e. one or two concretes, one sisters=True test), will
save me the trouble of going through this script and extracting
them myself.
here. The thing generates them now itself.
$python sa_ref_A_B_A_all.py relink
101 - 184 of 184 matches
Mail list logo