I'm just not getting it:
Want: select max(id) from table;
attempt (latest):
from sqlalchemy import *
from sqlalchemy.engine import reflection
from sqlalchemy import schema
from sqlalchemy import exc
from psycopg2 import *
import re
import time
import os
targethost = "192.168.181.204"
targetdb
On Wednesday, September 30, 2015 at 1:43:46 PM UTC-6, Michael Bayer wrote:
>
> there's no known bugs in fetching unique constraints. PG 8.4 is a pretty
> old version but should be working.
>
> note that a unique index and a unique constraint aren't listed as the same
> thing, however.you m
See below
On Tuesday, September 8, 2015 at 9:00:12 PM UTC-4, Michael Bayer wrote:
>
>
>
> you can get these like this:
>
> from sqlalchemy import inspect
> insp = inspect(my_engine)
>
> fk_constraints = insp.get_foreign_keys('mytable')
> uq_constraints = insp.get_unique_constraints('mytable')
>
Oh, Michael!
You have made my day. It just gets better and better!
I don't know how I missed these items, but your examples are very helpful.
Many thanks!
On Tuesday, September 8, 2015 at 7:00:12 PM UTC-6, Michael Bayer wrote:
>
>
>
> On 9/8/15 12:57 PM, Steve Murphy w
This message concerns using sqlAlchemy for schema based traversal and
manipulation.
It is the result of a project to transfer data from on database to another,
where objects
refer to each other, and must be copied to new rows in the target db, and
have all the
foreign references updated in the
Hmm, I don't think I could listen to the attribute event; it's saying that
the AssociationProxy doesn't have "dispatch".
Also, suppose I could detect the orphan-deletes earlier, what's the best
way to suppress the objects marked as dirty?
Here's my version of your code if it helps:
https://gi
Since my association object doesn't have extra columns, the row ('bob,
'apple') will be deleted. However, if there are extra columns, then having
it marked as "dirty" is desired.
Perhaps I would delay my recording of my audit rows until after orphans are
resolved. I am already using "after_flus
bob.keywords.remove(apple) <== this is when my question is
about
sess.commit()
When we remove the keyword, it marks the UserKeyword association object is
"dirty" instead of "deleted". Why is that? Since the row is being removed,
I would expect it to
My solution, since sqlalchemy seems to be ignoring the nullable and default
kwargs, is this:
time = Column(
TIMESTAMP(), primary_key=True,
server_default=text("'-00-00 00:00:00'"))
The default is just never used.
On Friday, January 10, 2014 12:2
I realize this thread is ancient, but I'm resurrecting it for Googleable
posterity since I just ran across the same issue.
The problem is that MySQL "helpfully" inserts the ON UPDATE cheese unless
you specify a default and/or a NULL/NOT NULL value in the CREATE TABLE
query.
http://dev.mysql.co
> you should only be dealing with timezone-naive datetimes within a
Python application
Thanks - make sense although the klugey way around the problem is just to
commit None before you change between naive and aware since comparisons
with None are fine.
--
You received this message because you are
When I try to commit a timezone aware datetime to replace a value that was
previously timezone naive, I get a TypeError when I try to do the commit
with the message:
TypeError: can't compare offset-naive and offset-aware datetimes
Now I am not trying to compare anything but just store the new val
Hi,
Thanks. Worked like a charm.
Also thanks for SqlAlchemy. A refreshing change for someone from java
background.
I am using this with Jython. Thanks for the Jython support also.
Steve
On Jan 18, 8:54 pm, Michael Bayer wrote:
> On Jan 18, 2011, at 9:11 AM, Steve wrote:
>
>
>
cessFactors.id).\
filter(ProbabilityModels.id == model_id).\
all()
Thanks in advance.
Steve.
--
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 f
> compare join.left, join.right, join.onclause
Thanks. That's what I needed.
--~--~-~--~~~---~--~~
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 uns
compare(obj2) is False
What is the best way to compare those two join objects and conclude they
represent the same join?
Steve
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to
> use query.statement to get at the SQL expression
Thanks. That worked.
--~--~-~--~~~---~--~~
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 unsubscri
is the second argument in visitors.traverse(). [It was missing
in the most recent example but apparently an empty dictionary is fine.]
Steve
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"sqlalchemy&q
same join again)?
Steve
--~--~-~--~~~---~--~~
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 emai
so I just need to work
around that. Again, thanks for the help.
Steve
--~--~-~--~~~---~--~~
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
to a
context_id = 0. Thanks for any advice.
Steve
--~--~-~--~~~---~--~~
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
that confused me.
It's working now, thanks, I needed the "ILIKE" function.
--
Best Regards,
Steve Howe
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this
te
cursor.execute(statement, parameters)
TypeError: 'dict' object is unindexable
I'm stuck. What should I be doing ? Use another syntax ? Replace psycopg2's
paramstyle to non-escaping mode ?
My environment:
Python 2.5.2
SQLAlchemy 0.5.0.rc3
PostgreSQL 8.30
psycopg 2.0.7
Thanks for the explanation, Michael. The behavior is very sensible
now that I see what's happening.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqlalchem
do want to thank zzzeek who very quickly provided workarounds in the
trac entry.
Thoughts? Is this the way it should be?
-Steve
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to
> be sure to clean out the .pyc files.
That worked. Thanks.
--~--~-~--~~~---~--~~
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 th
Trunk Rev 4726
Note the following:
Python 2.5.2 (r252:60911, May 7 2008, 15:19:09)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from sqlalchemy import *
Traceback (most recent call last):
File "", line 1, in
File "
> my hat's off to you for coming up with that relation(), it works again
> in rev 4486.
Ah the irony ... check out http://tinyurl.com/6kqv94
And thanks as always for your remarkable responsiveness and for
sqlalchemy. It is indispensi
n are foreign.
I am not sure what needs modification in the mapper to be compatible
with the current trunk.
Steve
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email
I am on current svn and have not tested expire but refresh is happy to
refresh an object that is not in the session.
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> item = session.que
This is probably obvious but I was confused by the fact that you can
refresh an object through session.refresh(obj) but that doesn't
guarantee that the object is in the session and doesn't put it in the
session if it is not. Is the accepted way to handle this to just
follow the refresh with a ses
> another option is:
> .query(Node).filter(not_(Node.id.in_(select([Node.parent_id]
jason, thanks for the alternative method. Steve
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" g
Michael,
Works perfectly. Thanks much.
Steve
--~--~-~--~~~---~--~~
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
t the right query is. Any help
would be appreciated.
Steve
--~--~-~--~~~---~--~~
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
Is it possible to create indexes using a function using sqlalchemy and
postgresql?
Something like: create index idx on table (lower(table.field))
Thanks,
Steve
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Michael, thanks for working through this and for taking the time to
explain what's going on and to provide alternative ways to getting
this done. Your efforts to support the users of sqlalchemy are really
extraordinary.
--~--~-~--~~~---~--~~
You received this mess
Here you go.
--~--~-~--~~~---~--~~
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 email to [EMAIL PROTECTED]
For mor
2429 still has the problem. Below are the relevant tables and classes:
item_table = Table('item',metadata,
Column('id', Integer, primary_key=True),
Column('uuid', String(32), unique=True, nullable=False),
Column('parent_uuid', String(32),
ForeignKey('ite
erwise. also the
> databases will often not give you back the same column name as what
> you gave it (case conventions, etc) and in some cases we dont even
> have a column name to start with (like "select some_function()").
>
> On Mar 17, 2007, at 8:41 PM, Steve Huffman wro
I hadn't updated in several weeks so I am not sure when this issue
first arose but with the following setup:
mapper(Section, section_table, properties = {'items': relation(Item,
backref='section'), 'keywords':relation(Keyword,
primaryjoin=and_(keyword_table.c.uuid==it
then my reply you're about to read is probably out-of-context.
On 3/17/07, Michael Bayer <[EMAIL PROTECTED]> wrote:
>
> sorry, i meant "cursor.description", not "cursor.metadata".
>
>
>
> >
>
--~--~-~--~~~---~--~~
You received this message because you are subscrib
s a
> psycopg2 version issue, then everyone can just upgrade.
which version are you using?
>
> On Mar 17, 2007, at 8:41 PM, Steve Huffman wrote:
>
> >
> > I may be missing something fundamental here, but why doesn't it
> > already know the metadat
I may be missing something fundamental here, but why doesn't it
already know the metadata since I defined the columns in which I'm
interested?
thing_table = sa.Table("thing", md, sa.Column('id', sa.Integer,
primary_key = True))
On 3/17/07, Michael Bayer <[EMAIL PROTECTED]> wrote:
>
> the cursor
ve to set
each attribute separately.
Thanks,
Steve Bergman
--~--~-~--~~~---~--~~
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
Works. Thanks.
--~--~-~--~~~---~--~~
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 email to [EMAIL PROTECTED]
For
Oops, I may have spoken too soon about things working...
The children relationship works fine and generates the correct query.
However, I don't think that the parent backref relationship is
generating the right query. item0.parent produces the following where
clause:
... WHERE ? = item.parent_
Works perfectly. Your responsiveness and the usefulness of SQLAlchemy
continue to amaze. Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@g
The table is the following:
item_table = Table('item', metadata,
Column('id', Integer, primary_key=True),
Column('uuid', String(32), unique=True, nullable=False),
Column('parent_uuid', String(32), ForeignKey('item.uuid'), nullable=True),
...
With mapper:
mapper(Item, item_table,
pro
I guess that should really be:
order.items.append((item('SA T-Shirt'), {'price':2.99}))
which looks awkward enough that I am happy to drop the point.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" g
I am probably the last person to comment on aesthetics but shouldn't
the syntax be:
order.items.append((item('SA T-Shirt'), price=2.99) )
to at least preserve Python-like list append syntax instead of:
order.items.append(item('SA T-Shirt'), price=2.99)
which admittedly looks simpler but is not
Prior to 2089, the following worked fine:
session.query(ItemKeyword).count()
where ItemKeyword has a compound primary key that is defined in its
mapper as follows:
mapper(ItemKeyword, itemkeyword_table, primary_key =
[itemkeyword_table.c.item_uuid, itemkeyword_table.c.keyword_uuid],
properties=
The diffs are a little hard when you're not sure where the line breaks
are (and the cascade all appears to be on the wrong line to me) but
just for my own sanity, you're saying that:
mapper(Item, items,
properties={'keywords':relation(KeywordAssociation,
cascade="all,delete-orphan")})
is equival
Current trunk. sqlite
Simple example below in which a Boolean with default = True is being
created with default of 0. The other defaults in the example below
work fine.
item_table = Table('item',metadata,
Column('id', Integer, primary_key=True),
Column('name',String
> the eager load should be able to go through the association object
> down to the endpoint Keyword objects
Thanks -- that does work.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to th
> youre really looking to have an association object pattern here.
I thought you might recommend that. My problem last time I tried an
association object was that in the following situation:
item table
keyword table
itemkeyword table (and association object)
I couldn't get the keywords to eager
Briefly, I have a situation in which a mapper works fine unless I
change loading to lazy=False on one of the relationships.
The mapper is:
mapper(Item, item_table, properties = dict(keywords = relation(Keyword,
secondary=itemkeyword_table, lazy=False, backref='items'),
display_keywords = relatio
> you could also do it just with custom properties on your class ...
Thanks -- that is a pretty simple way to do it.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send em
My question is about using Association Objects. While they certainly
make some things more natural, it seems that there is a price to pay
for not being able to do:
an_items_keywords = item.keywords
but to instead have to write
an_items_keywords = [ik.keyword for ik in item.itemkeywords]
which
58 matches
Mail list logo