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
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
36 matches
Mail list logo