]
COMMIT
Any help would be much appreciated!
James
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send
. These
are described
athttp://www.sqlalchemy.org/docs/05/sqlalchemy_orm.html#docstrings_sqla...
.
On Dec 5, 2008, at 11:42 AM, James Brady wrote:
Hi all,
I'm trying to get deletes and updates cascaded down from a parent
object to the child objects (connected by ForeignKey).
It all seems
Yep, the same behaviour in 0.5rc4
On Dec 5, 12:44 pm, James [EMAIL PROTECTED] wrote:
Ah, I should say I'm using SA 0.4.3 - I going to try the same test on
0.5
On Dec 5, 11:36 am, Michael Bayer [EMAIL PROTECTED] wrote:
actually, use passive_deletes=True, not 'all'. It will issue DELETEs
Ah! I see - I had the cascade and passive_delete arguments in the
wrong place.
This works as expected in 0.4.3 and 0.5 now.
Thanks for the help
James
On Dec 5, 12:47 pm, Michael Bayer [EMAIL PROTECTED] wrote:
Assuming user_id is a surrogate primary key, I dont see any need for
onupdate
Hi Michael, Thanks for your response on this.
the engine is using a connection pool which by default will keep five
connections opened persistently. It also has an overflow of 10
additional connections which are opened on an as-needed basis and
closed after usage. At the point of 15
Hello Again Michael,
This makes perfect sense to me, I've been looking at my application
log data this morning and can see the connections being created,
pooled and checked out exactly as I would expect which is a very good
sign.
I can however see that my application can potentialy see a
Afternoon Guys,
I have a suspicion that I'm leaving MySQL database connections open when I
shouldn't be and I'm trying to understand how they are managed by
SQLAlchemy.
I currently create an engine instance and bind my session maker too it like
this:
# Create the engine to
Guys,
Got an unusual error this morning when running a query, I keep getting:
Error writing file '/tmp/MYHo980S' (Errcode: 28)
Thrown at me, any ideas what this is all about?
What is it trying to write to the FS?
Cheers,
Heston
Quick question I hope guys.
If I have an object which contains a bunch of children and cascade is set on
the relationships. When I add the parent object to the session and commit
it, are the children saved as part of a transaction by default? Or do I have
to do something special?
If I
PROTECTED] On
Behalf Of Michael Bayer
Sent: 10 October 2008 15:25
To: sqlalchemy@googlegroups.com
Subject: [sqlalchemy] Re: object_session(remote_device_object) returns
noneType
On Oct 10, 2008, at 8:03 AM, Heston James - Cold Beans wrote:
Morning guys,
When calling object_session
Hello Guys,
I'm receiving errors in my application on a fairly regular basis now and I'm
not sure how to begin solving it.
Please find attached a backtrace for the error. It seems that its struggling
to connect to the MySQL server, however I get this after the application has
been running
Morning Guys,
I hope this'll be a fairly simple question. I have a query which looks
something like this:
the_objects = session.query(myobject.myobject).filter(myobject.created
:lastrecord).params(lastrecord=time.strftime(%Y-%m-%d %H:%M:%S,
from_date)).all()
This grabs all the records
PROTECTED] wrote:
first u get your query sorted in proper order (by timestamp or even
dbid, or hierarchicaly via subselect + groupby + order, whatever)
then yourquery[:1000]
On Wednesday 24 September 2008 14:11:24 Heston James - Cold Beans
wrote:
Morning Guys,
I hope this'll be a fairly
:27 pm, Werner F. Bruhin [EMAIL PROTECTED] wrote:
Heston,
Heston James wrote:
Hi,
Thanks for the response, that gave me a good foot in the door to this.
I've now appened my existing query with.
.order_by('myobject.created')[:1000]
Just tried this on a simple example:
query
Hello Guys,
This might seem like a bit of a naive question but I'm looking for your
advice. Being from the UK we operate on Daylight Savings Time which gives us
a one hour offset on times for a few months of the year.
I currently have a DateTime column which is declared like so:
Hi Werner,
IIUC func.now is a database function.
Ah, ok, that makes fair sense.
You should be able to use datetime instead i.e.:
created = Column(DateTime, default=datetime.datetime.utcnow)
modified = Column(DateTime, default=datetime.datetime.utcnow,
onupdate=datetime.datetime.utcnow)
Hello Guys,
I'm looking to send an object from SQLAlchemy across a ZSI web service as a
complex type. To do this ZSI requires that datetime's in the objects be in
Python Time Tuples as documented in the 'time' module.
It looks as if by default SQLAlchemy uses datetime.datetime objects for
Hi Kyle,
Thanks for the really thorough response, it seems you know what you're on
about :-) I agree with you that it would likely be a foolish decision to
rely on undocumented behaviour, this will likely come back to bite me at
some point in the future.
I'm going to take all these ideas away
Guys,
I want to run a query which doesn't return any objects, just simply modifies
all records in the table, like so:
UPDATE foo
SET bar = 0
How can I do this using SQLAlchemy? Is it possible and 'proper' for me to
just pass this query as a string
Afternoon All,
Hello Guys,
I have an object which I save to the database using SQLAlchemy, the class
is defined using
declarative and has a whole bunch of properties.
This object has one property though which isn't saved to the database, but
to the file system.
It is basically a binary
Hello Guys,
I have an object which I save to the database using SQLAlchemy, the class is
defined using declarative and has a whole bunch of properties.
This object has one property though which isn't saved to the database, but
to the file system. It is basically a binary string of a files
Hello Guys,
I'm looking to store a Boolean value in a MySQL 5.2 database. I'm then going
to describe a class for the table using declarative and have a couple of
questions on this:
What Datatype should my table column be set to in MySQL? And likewise, when
declaring the column using
I am using Column(Boolean) with declarative and MySQL and it is
working fine. In MySQL itself the type is 'tinyint(1)' but they
provide 'bool' and 'boolean' as synonyms if you prefer.
Bobby,
Thank you for this, I went with the tinyint(1) and it seems to be working
great!
Thanks,
Heston
Hi Rick,
I'm not sure where this is going with the 0.5 version,
but I believe that MappedClass.__int__ is still not called
when objects are loaded from the DB.
If that's the case, and there isn't some alternate that
SA provides like MappedClass.__onload__, You can look into
Mapper
Morning Guys,
I'm looking to build a uniform method for getting/creating instance of my
objects from the database. At the moment I've been using
query(SomeObject).get(object_id) to return the objects from the DB, however,
it would be really great if there were a method which always returned a
Afternoon Chaps,
I've got a query here which I've been looking to reconstruct from the
standard SQL into a SQLAlchemy statement which will return a list of objects
but I'm really struggling to make any headway on it, I'm hoping you'll be
able to offer me some help.
I have two objects in my
Hi Michael,
theres some experiments in IoC for Python if you google around for
dependency injection python, but the Python way is usually focused
around not really needing thick layers of abstraction like that.
Thanks for that. I did do some googling around a while back when first
Hi Michael,
create a file called something like globals.py, and in all other
modules that use SQLAlchemy, say import globals. A primer on
modules, packages and such is at http://www.python.org/doc/tut/node8.html
Excellent! This seems to have done the job, I am now successfully
Good morning guys,
I'm looking for a way in which I can query my database for records which
meet multiple, optional arguments. I'm looking to encapsulate access to this
using a service layer, I want to create a method like this:
def get_foos(self, foo_id=, foo_firstname=,
Hi Svil:
use keywordargs as dictionary, i.e.
...query.filter( **kwargs)
where the kwargs are a dict made by u containing only the required
fields. e.g.
kwargs={}
if foo_id: kwargs['fooid']=fooid
That sounds like a fair enough solution to me, seems safer than the more
generic version.
Hello Again Svil:
That sounds like a fair enough solution to me, seems safer than the more
generic version.
Thanks for the tip mate, sounds really great. I'll play around with that
concept.
Heston
I've tested this little concept and it works really nicely :-D thanks.
One quick question
Hi,
pass an echo=True to the create_engine() (or whereever else u could
pass that) and u'll see the sql.
Ok, I see! Perfect!
I've just configured logging on this so I can keep track, looks excellent.
Heston
--~--~-~--~~~---~--~~
You received this message
Afternoon Guys,
In my classic non-orm based applications I would usually inject other
business object instances into my classes for such things as logging,
emailing and all manner of other things. For instance:
class foo:
def __init__(self, logger, email_service, foo_id=,
Hi Michael,
what I see immediately is that you're declaring mutliple
declarative_bases and multiple MetaData objects. All of the Table
objects which relate to one another need to share the same underlying
MetaData object, and the declarative_base() function also uses a
MetaData
Hello Michael,
what I see immediately is that you're declaring mutliple
declarative_bases and multiple MetaData objects. All of the Table
objects which relate to one another need to share the same underlying
MetaData object, and the declarative_base() function also uses a
MetaData
Hi Michael,
declarative places a convenience __init__ that installs keywords as
attributes, but you're free to override this constructor with anything
you'd like.
Thank you for confirming this for me, I'd hoped I'd be able to override the
class constructor, I often use it for
i'm sorry for my misleading reply;(
i was kind of too sleepy last night;P
No problem my man.
Heston.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to
Column('created', DateTime, default=func.now()),
Column('updated', DateTime, onupdate=func.now()))
You can set both default= and onupdate= on the same Column if you want
'updated' to be non-NULL on insert.
That sounds like a nice clean way of doing this Jason, I'm more than
Hello Rick,
These mapper extensions look very good, I've used a similar concept in other
ORM's in the past for all manner of things and have a couple of decent ways
to utilize them in this current application.
Cheers,
Heston
From: sqlalchemy@googlegroups.com [mailto:[EMAIL
Good morning all,
So, this morning's challenge has been learning many-to-many relationships,
after reading through the tutorial I understand most of the core concepts of
how it should work but I'm struggling to actually make it do so, I thought I
would come and rely on you good people to help
NameError's are thrown usualy by import'ing or similar mechanisms.
have a look on your code.
eventualy post the whole traceback?
Hello Mate,
I think you're right, but the problem is that I don't know what I 'should'
be importing into the class. See, I have two files; Post.py and
the association table is an instance of Table,
and does not need its own class. It's easiest to declare
the association table in the same module as that which
it is used, in this case post.py.
Ok this sounds fine, I've done this now, declaring the table in the post.py
module.
When you
if u look up the stacktrace/traceback, u'll see which statement in
your own code triggered the error. is it in the mapping-part or is
still in table-declaration part?
do all 3 tables use same metadata?
Thank you for your comments so far, I appreciate you helping me out on this.
The entire
Session.add is a version 0.5 method, you're maybe running 0.4.6?
In the 0.4.x series, it's going to be:
Session.save() for objects that are to be newly added to the session
Session.update() for objects that are already in the session, or
Session.save_or_update() to have the library figure
If you define a column with column name contains capital letter, and
define CheckConstraint for this column, then DDL issued by SA will be
wrong.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To
Hi Florent,
On Oct 11, 1:01 pm, Florent Aide [EMAIL PROTECTED] wrote:
On 10/11/07, James Brady [EMAIL PROTECTED] wrote:
Did you call assign_mapper on Ownership?
[...]
However, I'm using the identity framework (part of TurboGears) which
unfortunately doesn't play nicely
, which currently has
a lot more on SQLObject...
So it seems from that tutorial that session.query... is the way to go
for these selects, and I need to learn how to manage the sessions
properly!
Thanks,
James
--~--~-~--~~~---~--~~
You received this message because
On Oct 10, 2:12 pm, Marco Mariani [EMAIL PROTECTED] wrote:
James Brady ha scritto:
The problem I'm hitting at the moment is how to properly select simple
objects... There seems to be two main approaches, for example:
session.query(Ownership).select() or
ownership_table.select
these specific questions or point me in the
direction of some further documentation?
Thanks,
James
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to sqlalchemy
just to make sure I'm understanding this:
even though mysql is configured to cascade deletes for this
relationship, SA needs to be told about it so that it doesn't prevent
it from cascading by first nulling the foreign key?
I tried this:
class Account(ActiveMapper):
class mapping:
='delete' and passive_deletes=True items belong?
thanks,
James
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from
column (below) based on example here:
http://www.sqlalchemy.org/docs/03/adv_datamapping.html
This did not work. Child rows not deleted.
Any help much appreciated!
James
INFO:
I have accounts with one-to-many users in model.py:
class User(ActiveMapper):
Reasonably basic User definition
call
in the account column (below) based on example here:
http://www.sqlalchemy.org/docs/03/adv_datamapping.html
This did not work. Child rows not deleted.
Any help much appreciated!
James
INFO:
I have accounts with one-to-many users in model.py:
class User(ActiveMapper):
Reasonably
which python reference (url?) are you speaking of?
how does 'import_fullname' work? how would it be applied?
On Jul 21, 11:35 am, [EMAIL PROTECTED] wrote:
In other words, should I first attempt to
__import__('vor.'+modname) in runJob() ?
see the python reference about how to use __import__
aaah, u are _that_ new...
- use it instead of the __import__() func
- original python library reference of the version u use;
e.g.http://docs.python.org/lib/built-in-funcs.html
wow there's a level parameter now... somethin to try
I'm not using 2.5 (2.4 still). I tried the 'my_import'
Ok, I just tried something that actually worked. WOO HOO!
First, I appended the sys.path var like this (relative, was absolute
before):
sys.path.append( 'vor')
combined with this:
...
module = my_import('vor.'+modname)
...
I realize that this is not ideal. But
-3: 2.5 or 2.4 all the same (Except abs/rel imports which still dont
work in 2.5 anyway).
-2: u need my_import (or similar) because __import__( 'vor.model')
will not give u want u want.
-1: u need to give _same_ full absolute paths to __import__ (or
substitute) or else u'll get duplicated
On Jul 23, 10:33 am, svilen [EMAIL PROTECTED] wrote:
First, I appended the sys.path var like this (relative, was
absolute before):
sys.path.append( 'vor')
IMO u should not touch sys.path unless u really really have no other
chance. Although this above is another wholesale
On Jul 23, 10:33 am, svilen [EMAIL PROTECTED] wrote:
First, I appended the sys.path var like this (relative, was
absolute before):
sys.path.append( 'vor')
IMO u should not touch sys.path unless u really really have no other
chance. Although this above is another wholesale
On Jul 20, 10:42 pm, [EMAIL PROTECTED] wrote:
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
I am creating a persistent job scheduler utility in my TG application
and have run into a minor issue regarding SqlAlchemy.
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:
I want to use order by and limit in a sub select, but it doesn't seem
to work:
Code
import pkg_resources
pkg_resources.require( sqlalchemy )
pkg_resources.require( pysqlite )
from sqlalchemy import *
metadata = BoundMetaData( 'sqlite:tmp/test.db' )
metadata.engine.echo = True
101 - 162 of 162 matches
Mail list logo