I'm having some difficulty using SQLAlchemy's jsonb operators to produce my
desired SQL.
Intended SQL:
SELECT *
FROM foo
WHERE foo.data-'key1' ? 'a'
...where `foo.data` is formatted like this:
{
'key1': ['a', 'b', 'c'],
'key2': ['d', 'e', 'f']
}
So, I'm
Test data attached. Perhaps I'm doing something else wrong?
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this
`type_coerce()` did the trick. Thanks, Mike!
On Wednesday, March 18, 2015 at 12:55:57 PM UTC-4, Michael Bayer wrote:
try using the type_coerce() function instead of cast, it should give you
the
has_key() but won’t change the SQL. (type_cast(Foo.data[‘key’],
JSONB).has_key())
just a
Thanks, Jonathan. I must have read your earlier post a dozen times, and it
certainly pointed me in the right direction -- at least, enough to get my
query working.
I'm going to study your test a bit -- thanks for posting it.
--
You received this message because you are subscribed to the
With the following model, I can currently set postgres range data types in
2 ways:
*Model:*
from sqlalchemy.dialects.postgresql import INT4RANGE
class Foo(Base):
__tablename__ = 'foo'
id = Column(Integer, primary_key=True)
bar = Column(INT4RANGE)
*Method #1 - as string data type:*
Sqlalchemy seems to be coercing the upper boundary to be exclusive. See
below tests (will need to change postgres db if you want to run them).
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.dialects.postgresql
Actually, looks like the problem is with psycopg2's handling of range
types, specifically with integers. Test attached. Will forward to psycopg2
maintainers.
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To unsubscribe from this group and stop
Hi Mike,
I'm using your variant on the 'unique object' recipe (see previous
posting http://goo.gl/I1buRz) with some composite association proxies.
Recently, the data I've been working with introduced a duplicate in the
property I've been using with attribute_mapped_collection(), so I'm trying
Hmmm, must be a problem elsewhere. Sorry for wasting your time, Mike, but
thanks for the test case. Donation enroute.
On Tuesday, July 8, 2014 12:02:52 PM UTC-4, Michael Bayer wrote:
a test case is attached, show me the failure please, thanks.
On 7/8/14, 10:59 AM, Brian Findlay wrote
Ok, Mike. Thanks.
Ended up removing the trigger from the model and pushing that code to the
controller, so that foo updates the bar attribute after form data with
UserCourse objects is handled.
On Wednesday, July 2, 2014 9:42:11 PM UTC-4, Michael Bayer wrote:
On 7/2/14, 2:59 PM, Brian
Hi Mike (et al.),
I'm searching for a way to achieve defaultdict-like functionality for
association proxies, so that a function that refers to a collection (or key
within that collection) before it exists can create the collection/key with
a default value.
In a previous post
to take the focus off the
function itself in order to troubleshoot the event sequencing.
-Brian
On Wednesday, July 2, 2014 1:43:59 PM UTC-4, Michael Bayer wrote:
On 7/2/14, 11:15 AM, Brian Findlay wrote:
I've since added an event listener to perform a calculation each time
a UserCourse
My project requires querying an externally-managed database as well as a
project-specific database. What I've been doing to date is copying the
external database (which changes very infrequently) into the
project-specific database so I only need one engine and one dbsession. I'm
now trying to
Not sure if __abstract__ is the way to go. Should I instead be creating
mixins?
http://docs.sqlalchemy.org/en/rel_0_9/orm/extensions/declarative.html#mixin-and-custom-base-classes
On Saturday, April 26, 2014 5:07:23 PM UTC-4, Brian Findlay wrote:
My project requires querying an externally
Continuing to troubleshoot. This produces the same exception:
DBSession.configure(binds={DB1: db1_engine, DB2: db1_engine})
Note that I'm binding both classes to the original engine. I thought it
would be the same as the working config:
DBSession.configure(bind=db1_engine)
--
You received
Thanks, Mike. Will check this out.
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to
I'm almost certainly exposing my level of ignorance here, but does this
mean I could just replace
DBSession.configure(binds={DB1:db1_engine, DB2:db2_engine})
with
DBSession.configure(class_=MySession)
?
I suppose I could even use
DBSession = scoped_session(sessionmaker(class_=MySession,
Hi,
Running python 3.3.4, pyramid 1.5b1, sqlalchemy 0.9.3.
A couple of months ago Mike helped to set up composite association proxies
in my model (
https://groups.google.com/forum/#!searchin/sqlalchemy/composite$20association$20object/sqlalchemy/kxU-FaDGO2Q/b8ScnTXvPyIJ).
I'm applying this
Thanks, Mike.
I found some records in the occupations table without interest values in
the occupations_interests table, explaining the KeyErrors. Facepalm.
-Brian
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To unsubscribe from this group
Hi, all. I've been trying to modify the example of a composite association
proxy
(http://www.sqlalchemy.org/docs/orm/extensions/associationproxy.html#composite-association-proxies)
to fit my needs.
In the documentation example, there is a User object, a Keyword object, and
a UserKeyword
Well, if it isn't the man himself. Mike, you're awesome -- thanks for the
hand-holding. Thanks for reading into my use case and providing the second
example.
Also, thanks for the thorough documentation (on SQLAlchemy and Mako). This
would be infinitely more difficult without it.
On another
Mike,
It took a few hours to wrap my head around your work and adapt it to my
actual use case, but it's working great now...except for a particular case
when used with templates.
Basically, I'm querying for relevant courses and then iterating over the
results to construct a form for grade
22 matches
Mail list logo