k to avoid circular imports.)
In other words, is there a function that can do `model_cls =
looup_model(model_name)`?
Thanks,
Josh
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and
commit and apply it yourself?
--
Josh A.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
Hey I'm getting some intermittent ObjectDeletedError's that I don't really
understand.
The code I use looks like this:
> DBSession.begin()
> instance = DBSession.query(OrmOjbect).get("primary_key")
> DBSession.rollback()
>
>
> x = instance.attribute1
Probably 90% of the time the
of the
instance.
On Wednesday, October 21, 2015 at 4:11:32 PM UTC-5, Josh Jaques wrote:
>
> Hey I'm getting some intermittent ObjectDeletedError's that I don't really
> understand.
>
>
> The code I use looks like this:
>
>
>> DBSession.begin()
>> instance = DBSessi
I created an actual repo for this, so if anyone finds bugs, or wants to
submit patches:
https://github.com/deontologician/netezza_sqlalchemy
On Tue, Mar 4, 2014 at 7:18 PM, Josh Kuhn deontologic...@gmail.com wrote:
Since there wasn't one out there already, I took a shot at it. It's really
I have a situation where I need to produce a select object, and then later,
one of the fields needs to be zeroed out conditionally.
so something like:
def select_ab(param):
from_obj = join(A, B, A.c.b == B.c.b)
return select([A.c.a, B.c.b, B.c.d], from_obj=from_obj).where(A.c.a ==
param)
...@zzzcomputing.comwrote:
On Mar 27, 2014, at 10:08 AM, Josh Kuhn deontologic...@gmail.com wrote:
I have a situation where I need to produce a select object, and then
later, one of the fields needs to be zeroed out conditionally.
so something like:
def select_ab(param):
from_obj = join
distribute on
clauses to create table statements, and ensuring limit clauses don't get
sql params (since it doesn't like that).
With pandas incorporating SQLA, I figure this might be useful to some
people out there.
--Josh
--
You received this message because you are subscribed to the Google Groups
Thanks for the reply! I'll add the info property. Glad to see I wasn't
going about this completely the wrong way
On Sun, Feb 23, 2014 at 1:16 PM, Michael Bayer mike...@zzzcomputing.comwrote:
On Feb 23, 2014, at 12:59 AM, Josh Kuhn deontologic...@gmail.com wrote:
I'm writing some code
I'm writing some code to serialize some SA models to JSON, and for columns
and relationships, it's convenient to tag which fields should be serialized
with the info dictionary like so:
class Thing(Base):
id = Column(Integer, primary_key=True, info={'jsonify': False})
name = Column(String,
I think you need to use the remote_side argument for the children
relationship, since it's the same table
http://docs.sqlalchemy.org/en/rel_0_9/orm/relationships.html#adjacency-list-relationships
On Thu, Feb 13, 2014 at 12:04 PM, Michael Bayer mike...@zzzcomputing.comwrote:
On Feb 13,
I don't know if this is what you're thinking, but you can also just build a
query object in different ways if you want to
query = session.query(Study).options(
joinedload(Study.system),
joinedload(Study.site)).
I've got a two tables I'd like to create a relationship for. One is the
object, and another tracks versions.
Here's a gist with the setup:
https://gist.github.com/deontologician/8744532
Basically, the object doesn't have a direct reference to the current
version stored in the table. Instead, the
I'm trying to get a certain access pattern to work and I need a bit of help:
https://gist.github.com/deontologician/5922496
What I'm trying to do is use an association proxy to create a view of a
collection that looks like a list of dictionaries (for serializing to
json). I also want to update
I've attempted the following:
from sqlalchemy import Column, Integer, String, ForeignKey, create_engine
from sqlalchemy.orm import sessionmaker, relationship
from sqlalchemy.event import listen
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.associationproxy import
On Wed, Jul 3, 2013 at 7:30 PM, Michael Bayer mike...@zzzcomputing.comwrote:
@event.listens_for(Gadget, before_insert)
def before_gadget(mapper, connection, target):
target.machine_id = target.widget.machine_id
2. when widget is updated, gadgets need new machine_id, here UPDATE is
Your User class is mapped to a Table. It's not the Table itself. To get the
update method, you need to access User.__table__.update
On Fri, Jun 7, 2013 at 4:12 PM, Michael Nachtigal
michael.nachti...@catalinamarketing.com wrote:
After reading the documentation, I am under the impression that
I'm running web service using sqlalchemy with apache + wsgi + pyramid
framework.
I've initialize metadata like the following:
Base = declarative_base()
Base.metadata.reflect(bind=my_engine)
user_table = DP_Base.metadata.tables[user]
mapper(User, user_table)
and I'm using scoped session since
User class extends object, not Base.
Actually User class is imported from another package, which is made by my
coworker, and I need to separate my work from his. So I have no choice but
using classical mapping since the User class is intended to be used with
classical mapping.
--
Josh Ha
I've made web application using Pyramid 1.2.5 + Python 2.7.1 + SQLAlchemy
0.7.4 and occasionally encountered the following error.
Traceback (most recent call last):
File /usr/local/lib/python2.7/site-packages/pyramid/router.py, line
176, in __call__
response = self.handle_request(request)
I'm connecting to an Oracle database for my work and we do replication
by periodically joining tables across sites instead of a single server
just in case a link in between goes down. One issue with this though
is I need to generate unique keys for a single table so if the
connection does go
that
you're using table.create(), metadata.create_all(), or sequence.create() to
issue the CREATE SEQUENCE call. The INCREMENT BY and START WITH clauses
should be emitted as of the 0.6 series of SQLAlchemy.
On Feb 4, 2011, at 2:10 PM, Josh Stratton wrote:
I'm connecting to an Oracle database
I'm currently interfacing with an Oracle db using sqlalchemy without
any sessions or mappings. Selects and inserts work great, but I'd
like to be able to update a row without having to delete and reinsert
it.
# remove the id
table.delete(table.c.id == row['id']).execute()
I'm attempting to use joined table polymorphism for various types of
activities. Activities all share a few common features, a location, a
reference number, time, etc. but some have some further attributes.
When I set up my map like so:
mapper(Activity, activities,
On Apr 6, 4:27 pm, Michael Bayer mike...@zzzcomputing.com wrote:
On Apr 6, 2010, at 3:56 PM, Josh Winslow jwins...@gmail.com wrote:
I'm attempting to use joined table polymorphism for various types of
activities. Activities all share a few common features, a location, a
reference number
you'd need to establish the primary key from the mapper's point of
view in terms of both userId and userName. mapper() accepts a
primary_key argument for this purpose.
That kind of surprises me sqlalchemy isn't aware of what's a primary
key and what isn't. Looking at the docs, it states
OK, you have the unique constraint on userName alone. that means that you
*cannot* have two rows like this:
userId userName
1 someuser
2 someuser
Right.
because unlike a primary key that consists of userId and userName, the
distinctness here of userName is
I just figured the mapper had to be called every time as it didn't
just compile the class, but actually needed a database table to map to
and wasn't sure what was done under the hood to setup that up and if
it was valid for another database.
Just to be sure, but would using a mapper setup as
From what I've read of sqlalchemy, I originally wanted to have a main
table with one attribute foreign keyed to another table's
autoincremented integer primary key userId and a userName. I thought
I could join the tables together and set that as the mapper. The save
every object in my
this is always easily worked around by specifing the ON clause to your
join(), as the second argument of table1.join(table2,
and_(table1.c.foo==table2.c.bar, table1.c.bat==table2.c.hoho, ...)).
Ah, okay. No foreign key, just a join. For reference, this was what
I ended up going with.
j =
2. load-each-row-at-a-time
just remove the first query. the session will then look up things using
merge() as you ask.
But wouldn't this still cause an insertion error when I try merging a
job object, who's userName is already in the table?
What is the purpose of class_mapper? I can't find it in the .4 docs
for the tutorials I'm looking at, yet when I don't call it as
https://svn.enthought.com/svn/enthought/sandbox/EnvisageSQLAlchemy/enthought/sqlalchemy/has_traits_orm.py
notes, I get a
AttributeError:
#
popular, since it performs both at the
same time by definition.
Okay, that seemed to work. Thanks. A mapper() call followed by a
class_mapper() call for each database did the trick.
Josh
--~--~-~--~~~---~--~~
You received this message because you are subscribed
AttributeError: 'MyObject' object has no attribute '_state'
I don't see any _state printed out. The only additional attribute I
see is the 'c' variable, where pull tables from. What is causing this
_state thing to appear? Do I need to call class_mapper after each
mapper only only once
On Apr 2, 9:21 pm, Michael Bayer zzz...@gmail.com wrote:
On Apr 2, 4:41 pm, Josh Winslow jwins...@gmail.com wrote:
This is the stack trace:
⇝ InvalidRequestError: The transaction is inactive due to a rollback
in a subtransaction. Issue rollback() to cancel
On Apr 3, 10:13 am, Michael Bayer mike...@zzzcomputing.com wrote:
Josh Winslow wrote:
On Apr 2, 9:21 pm, Michael Bayer zzz...@gmail.com wrote:
On Apr 2, 4:41 pm, Josh Winslow jwins...@gmail.com wrote:
This is the stack trace:
⇝ InvalidRequestError
I'm currently suffering from a rare and hard to pin down bug that
seems to be living somewhere in contextual session code. As part of a
formencode schema, I'm checking to make sure that a submitted form
value matches a record in the database. From tracing through the
request lifecycle, it
37 matches
Mail list logo