Hi,
I have a script that's basically been running unmodified for years. In it, it
performs an SQLAlchemy query that does a simple join between two tables:
platePointing =
session.query(PlatePointing).join(Plate).filter(Plate.plate_id==plateid).one()
Suddenly, I'm getting a NoResultFound error
On Mar 28, 2014, at 6:40 AM, Simon King si...@simonking.org.uk wrote:
The alternative is to define the children relationship after the
class has been defined:
class PhotoObj(Base):
__tablename__ = 'photoobj'
__table_args__ = {'autoload':True, 'schema':'sdssphoto'}
Hi,
I'm trying to configure a table with autoload but can't quite get the syntax to
set up a self-relationship. This is my abbreviated) schema:
CREATE TABLE sdssphoto.photoobj
(
pk bigint NOT NULL DEFAULT nextval('photoobj_pk_seq'::regclass),
parent_photoobj_pk bigint
CONSTRAINT
Hello,
Thanks Mike for the comments. Before I answer the questions you asked, I want
to note I found a workaround without making any changes to the database-- I
just reversed the tables in the definition. At first I was using:
Survey.bossSpectrumHeaders = relationship(BOSSSpectrumHeader,
Hi,
I'm getting the following error with SQLAlchemy 0.7.3:
sqlalchemy.exc.ArgumentError: Could not determine join condition between
parent/child tables on relationship Survey.bossSpectrumHeaders. Specify a
'primaryjoin' expression. If 'secondary' is present, 'secondaryjoin' is needed
as
Hi M,
Thanks very much for your help. Adding .with_lockmode('update') to my
session.query statement worked like a charm!
Now I just need to figure out how to catch exceptions that occur in the work
unit in the thread, but that's a topic for another list...
Cheers,
Demitri
--
You received
Hi,
I'm working on a script using SQLAlchemy against a PostgreSQL database and
using Python's multiprocessing. The pattern is for each thread to:
- start a transaction (session.begin())
- retrieve the next row in table X that has not yet been processed
- set a being_processed flag in the row so
Hi,
I'd like to write a script that creates an in-memory SQLite database via
SQLAlchemy, but when I've finished with it I'd like to upload it as a file to a
server, preferably without ever creating a temporary file on the client side.
Is this possible?
Cheers,
Demitri
--
You received this
Thanks for the pointers. I'l probably just write it to a file initially to keep
it simple!
Cheers,
Demitri
--
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
Hi,
I just want to check on something. Let's say I've got a script that's
populating a database and will commit the transaction at the end. It looks for
a particular object (let's call it A), and if NoResultFound it creates a new
object and does a session.add(A).
What if in a later iteration
Thanks for the quick reply!
On Nov 12, 2010, at 7:41 PM, Michael Bayer wrote:
mm, right there that's not the default behavior. If you did an add(A), the
next query() you do will autoflush. A is now in the database within the
scope of the current transaction, so query() will find it.
Yes,
Hi,
Just wanted to say thanks to those who helped me with this. Simon's solution
was exactly what I was looking for (though I have to admit I don't exactly
understand *how* it works!). But that's no longer an SQLAlchemy question...
Cheers,
Demitri
On Jul 8, 2010, at 5:49 AM, King Simon-NFHD78
Hi,
Is lazy loading supported on a column by column basis, or only through
relationships?
Cheers,
Demitri
--
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
On Jul 19, 2010, at 4:08 PM, Michael Bayer wrote:
so its going to be doing that somewhat inefficient isinstance(list) thing
you see below, this appears to be how it handles arrays of arbitrary numbers
of dimensions. This could be optimized if the ARRAY type accepted some clues
as to how
Hi Michael,
Assuming I understood you correctly, I tried the code below. The result was the
same (the query took 486 seconds). Since I autoload everything, I first adjust
the column types to the class you defined. Did I misunderstand something?
Thanks again for your help.
Cheers,
Demitri
---
Hi,
Pasted below is a profile of the earlier code posted. I did update it with your
new definition of ARRAY Michael, but that only shaved off 18 seconds (down to
468s total) when run without the profiler.
The large number of __new__ calls roughly tracks with the number of numeric
values
Hi,
I have a question that I can't find a satisfactory answer to. Apologies in
advance if it's more of a Python question, but it's possible that there is a SA
solution.
I have a project that defines a database connection and classes based on
database tables. A script that uses these classes
Hi Lance,
Thanks for your comments.
On Jul 7, 2010, at 12:28 PM, Lance Edgar wrote:
Why not just do this in project2 ?
import project.DatabaseConnection as db
Base = declarative_base(bind=db.engine)
# ... etc.
The DatabaseConnection class contains the particulars of the connection
Hi,
I'm hoping someone can help me with properly configuring a session/
transactions for multiple uses as I haven't been able to get it quite
right.
I've created a python module to contain my model classes and a
connection class. This module wil be imported by both single-use
scripts
Hi Michael,
Thanks for clarifying that for me. For anyone interested, this is what
I ended up with:
from sqlalchemy import String
sa_major_version = sqlalchemy.__version__[0:3]
if sa_major_version == 0.5:
from sqlalchemy.databases import postgres
Hello,
I have a custom type defined in my postgresql database, and this is
giving me the warning:
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-
packages/sqlalchemy/engine/base.py:1265: SAWarning: Did not recognize
type 'fibertype' of column 'fiber_type'
Hi Tomasz,
Thanks for your help - that solved the problem.
On 26 Sep 2009, at 10:20, Tomasz Jezierski - Tefnet wrote:
[...code snipped...]
First... why don't you define this method with class definition? I
don't
use reflection but I think that it is possible...
It's a
Hi,
I'm trying to create a custom/derived attribute on a table class. This
is what I have defined:
class Plate(Base):
__tablename__ = 'plate'
__table_args__ = {'autoload' : True}
class Design(Base):
__tablename__ = 'design'
__table_args__ = {'autoload' : True}
On 19 Aug 2009, at 18:32, Mike Conley wrote:
The delete method of query supports bulk deletes.
In your case it might be something like
session.query(Users).filter(User.officeid==office.id).delete()
Any query can be used; there are probably more elegant ways to take
advantage of the
Hello,
I have several objects from a relation that I'd like to delete. To me,
this would be a natural syntax:
session.delete(office.users)
to delete all of the user objects. I get this error when doing this:
raise exc.UnmappedInstanceError(instance)
Hi,
I'm circling around an answer for a problem but am not quite getting
it. I have two tables: Plugging and Cartridge. Plugging has a to-one
relation to Cartridge, and the inverse relation is to-many. Cartridge
has a field called number and plugging has a field called active.
I want to
Hi,
I am doing a search across two tables for matching records, and I'm
not quite sure how to work with the results of the query. For example:
matches = session.query(TableA).from_statement(SELECT tableA.id,
tableB.id FROM tableA, tableB WHERE etc)
To me this doesn't really fit the model.
Hi Michael,
On 1 May 2009, at 20:50, Michael Bayer wrote:
obj in session.new
obj in session.dirty
obj in session
Cheers for that. I was actually on the right page in the documentation
when I was looking for that.
Hi,
Given a session object, is there a way to test if an object in the
session is pending (or for that matter, transient, persistent, or
detached)?
Thanks!
Demitri
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Hi Huy,
Thanks for your comments!
On 22 Apr 2009, at 05:33, huy wrote:
I guess it depends if you are going the standard SA table/mapping way
or the sqlalchemy.ext.declarative way
So this is a good question to ask. As I'm just starting out with SA, I
have no legacy code to update, and thus
Hello,
I'm trying to set up database access using SQLAlchemy, and wanted to
get some advice from the experts on how to proceed. I'm using
PostgreSQL as my database (shouldn't be important, I know) and will
specify foreign keys in the database. I do not want to create or
modify database
Hello,
I have a question about SQLAlchemy (well, I have a lot of questions,
but I'll try to space them out a bit!). I'm very new to it (and
python) but not databases and ORMs.
I like that I can use reflection to define tables, and I really want
to use that since I don't want to update
32 matches
Mail list logo