Hi,
I am using SQLAlchemy 0.6.4 with postgres db. I have two tables - users and
addresses tables with addresses table having a foreign key constraint
referencing the users table. Each address record is identified by a unique
constraint key 'email_address'.
In my test case, each user instance have
-Original Message-
From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com]
On Behalf Of jos.carpente...@yahoo.com
Sent: 26 July 2011 18:27
To: sqlalchemy@googlegroups.com
Subject: [sqlalchemy] Updating records in table not working
I'm using Postgres as a database.
Hi,
instead of db.session.add, what you want is:
import = db.session.merge(import)
See http://www.sqlalchemy.org/docs/orm/session.html#merging : It examines
the primary key of the instance. If it’s present, it attempts to load an
instance with that primary key (or pulls from the local
On Wednesday, 27 July 2011 08:23:14 UTC, Simon King wrote:
I've looked at the SA documentation and as far as I can see the 'add'
does an insert or an update.
I think this is incorrect - 'add' always corresponds to 'INSERT'
Only for brand new instances, not associated with a session. For
-Original Message-
From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com]
On Behalf Of Gunnlaugur Briem
Sent: 27 July 2011 10:36
To: sqlalchemy@googlegroups.com
Subject: Re: RE: [sqlalchemy] Updating records in table not working
On Wednesday, 27 July 2011 08:23:14
Hi,
you need to join explicitly on A.b:
SESSION.query(A).join(A.b).order_by(B.name)
Full example: http://pastebin.com/uMqEa6Cr
Regards,
- Gulli
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To view this discussion on the web visit
Hi all,
I'm trying to use session to execute a query against two databases;
is it possibile?
Ex. sql:
select db1.table1.col1, db2.table2.col2
from db1.table1 inner join db2.table2 on db1.table1.key =
db2.table2.key
With sessions:
session.query(Table1).join(Table2,
Hello,
I'm currently writing my own version of the magic orm. I'd like it
to generate id columns automatically. I tried it like shown below.
When using the code I get an exception:
ArgumentError: Mapper Mapper|Version|version could not assemble any
primary key columns for mapped table 'Join
On Jul 27, 2011, at 2:12 AM, Matthias wrote:
Hello,
I'm currently writing my own version of the magic orm. I'd like it
to generate id columns automatically. I tried it like shown below.
When using the code I get an exception:
ArgumentError: Mapper Mapper|Version|version could not
On Jul 27, 2011, at 5:52 AM, King Simon-NFHD78 wrote:
-Original Message-
From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com]
On Behalf Of Gunnlaugur Briem
Sent: 27 July 2011 10:36
To: sqlalchemy@googlegroups.com
Subject: Re: RE: [sqlalchemy] Updating records in
On Jul 27, 2011, at 3:34 AM, ammar azif wrote:
Hi,
I am using SQLAlchemy 0.6.4 with postgres db. I have two tables - users and
addresses tables with addresses table having a foreign key constraint
referencing the users table. Each address record is identified by a unique
constraint key
I have the following statement :
SELECT name, id, division, value,
FROM (
SELECT name, id, division,value, max(value) over
(partition by division) as max_val
FROM tab1
)
WHERE value = max_val
I try to turn this sql statement into a Query object
I tried
0.7 has support for window functions. I haven't tried it in a subquery.
http://www.sqlalchemy.org/docs/core/tutorial.html?highlight=window#window-functions
--
Mike Conley
On Wed, Jul 27, 2011 at 9:16 AM, Eduardo ruche...@googlemail.com wrote:
I have the following statement :
SELECT name,
I like to use a stored procure which needs a input parameter in
something like this:
seltest = db.sa.select([id,
name]).select_from(db.sa.func.someStoredProc(2)).alias()
seltestm = db.sao.mapper(ATest, seltest, primary_key=[seltest.c.id])
result = session.query(seltestm).get(73)
above works,
And the recipe I have used is to issue a flush() after the deletes and
before the inserts. In most cases this is sufficient to get things to work
in the right order. I can imagine that there are some complex data
management use cases where that is not sufficient. It works for your sample
as the
On 07/27/2011 10:42 AM, werner wrote:
I like to use a stored procure which needs a input parameter in
something like this:
seltest = db.sa.select([id,
name]).select_from(db.sa.func.someStoredProc(2)).alias()
seltestm = db.sao.mapper(ATest, seltest, primary_key=[seltest.c.id])
result =
Thanks for your help!
I found the solution :) Instead of doing
dict_['id'] = Column(...)
I just do
cls.id = Column(...)
and it works. Kudos to the writer of this wiki entry
http://www.sqlalchemy.org/trac/wiki/UsageRecipes/AutoSequenceGeneration
. The comments in there led me to the solution
Under 0.5 I was able to turn echo on and off as desired to support
debugging; it doesn't seem to work now.
Python version: 2.7.1
SQLAlchemy version: 0.7.1
Here's the code:
from sqlalchemy import *
eng1 = create_engine('sqlite:///')
meta1 = MetaData(bind=eng1)
tab_a = Table('x', meta1,
I have the following mapper:
orm.mapper(Xxx,xxx_table, inherits=Resource,
polymorphic_identity=u'xxx',
properties={'children' : orm.relation(Xxx,
backref=orm.backref('parent', remote_side=[Xxx.c.id]),
-Original Message-
From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com]
On Behalf Of Mike Conley
Sent: 27 July 2011 17:43
To: sqlalchemy@googlegroups.com
Subject: [sqlalchemy] engine.echo not working as expected
Under 0.5 I was able to turn echo on and off as
I saw that, but unless setting echo actually changes the Python logger
configuration I don't see how it applies here.
--
Mike Conley
On Wed, Jul 27, 2011 at 12:31 PM, King Simon-NFHD78
simon.k...@motorolasolutions.com wrote:
-Original Message-
From: sqlalchemy@googlegroups.com
No Python logging calls are emitted, which means, log.info() and log.debug()
*are not called at all*, if logging.isEnabledFor() returns False, which itself
is only checked upon Connection construction. These calls are all
unreasonably expensive so they aren't used if not necessary.
That's
A single SQL statement cannot emit a query against two distinct database
connections.There are ways to get a single database connection to access
two databases behind the scenes using a technology like Oracle's DBLINK. I'm
not sure what other vendors provide for this.
This all assumes by
On Jul 25, 2011, at 9:47 AM, Aviv Giladi wrote:
I can't seem to make cascade deletes work in sqlalchemy.
I have a parent class (called Rating), a sub class (Subrating) and a
third class called SubRatingProperty.
There is a one-to-one relationship between Rating and SubRating - each
Howdy,
I'm aggregating data from several Sqlite files into a Postgres db.
The sqlite files are storage for several apps I use: Shotwell,
Firefox, Zotero, Banshee ... I just watch and pull from them.
I've been using import sqlite3 so far, dumping sql from sqlite,
using it to create the Postgres
On Jul 27, 2011, at 3:21 PM, Kent Tenney wrote:
Howdy,
I'm aggregating data from several Sqlite files into a Postgres db.
The sqlite files are storage for several apps I use: Shotwell,
Firefox, Zotero, Banshee ... I just watch and pull from them.
I've been using import sqlite3 so far,
Hi there,
I am trying to follow the setup in this example
http://www.sqlalchemy.org/trac/browser/examples/beaker_caching to
enable beaker caching in sqlalchemy. However, I ran into an issue.
#1. When I try to cache a relation that happens to be an association
proxy I get the following error:
I seem to have solved it by aliasing the first instance too
query = sqlalchemy.orm.query(Xxx)
*alias = SA.orm.aliased(Xxx)*
query = query.join(*(alias,'parent')*, aliased=True)
query = query.filter(some criterion)
But this
Most databases allow ordinal numbers as expressions in order by clauses,
some even in group by clauses. And in earlier versions of SQLAlchemy it
had in fact been possible to express these as integers, e.g.
query.order_by(1, 3, desc(2)).
However, in version 0.7.1 this yields an SQL expression
Another issue I run into intermittently is the following:
TypeError: can't pickle function objects
Module myproject.lib.account_api:98 in get_user view
get(user_id)
Module sqlalchemy.orm.query:637 in get view
return self._get(key, ident)
Module sqlalchemy.orm.query:1968 in
On Jul 27, 2011, at 1:14 PM, Moshe C. wrote:
I have the following mapper:
orm.mapper(Xxx,xxx_table, inherits=Resource,
polymorphic_identity=u'xxx',
properties={'children' : orm.relation(Xxx,
On Jul 27, 2011, at 5:30 PM, Christoph Zwerschke wrote:
Most databases allow ordinal numbers as expressions in order by clauses, some
even in group by clauses. And in earlier versions of SQLAlchemy it had in
fact been possible to express these as integers, e.g. query.order_by(1, 3,
Hi,
I am actually using both MySQL and SQLite (one on the dev machine, one
on the server).
Does that make a difference?
On Jul 27, 12:26 pm, Michael Bayer mike...@zzzcomputing.com wrote:
On Jul 25, 2011, at 9:47 AM, Aviv Giladi wrote:
I can't seem to make cascade deletes work in
Good day,
I'm trying to figure out how to do something similar to the Symmetric
Encryption recipe (http://www.sqlalchemy.org/trac/wiki/UsageRecipes/
SymmetricEncryption), only on the database side, not in Python.
I have a suspicion that @compiles decorator may provide a solution,
but having
On Jul 27, 2011, at 8:56 PM, Sergey V. wrote:
Good day,
I'm trying to figure out how to do something similar to the Symmetric
Encryption recipe (http://www.sqlalchemy.org/trac/wiki/UsageRecipes/
SymmetricEncryption), only on the database side, not in Python.
I have a suspicion that
35 matches
Mail list logo