Let's say I have the following model:
class Molecule(Base):
db = Column(Integer, primary_key=True)
id = Column(Integer, primary_key=True)
data = Column(Integer)
class Atom(Base):
id = Column(Integer, primary_key=True)
weight = Column(Integer)
And I want to establish a
Finally figured out how to do it :
molecule2atom = Table(
'molecule2atom',
Base.metadata,
Column('molecule_db', Integer),
Column('molecule_id', Integer),
Column('atom_id', Integer, ForeignKey('atom.id')),
ForeignKeyConstraint(
('molecule_db', 'molecule_id'),
('molecule.db',
This is an unusual way to update an object that you've already retrieved:
result = session.query(Executions). \
filter_by(id=execution_id).first()
if result.end_date is None:
e =
update(Executions).where(Executions.id==bindparam(execution_id)). \
These tips are veeery good!
I sometimes get lost about the best way to use the best ORM library in the
world.
2013/3/7 Simon King si...@simonking.org.uk
This is an unusual way to update an object that you've already retrieved:
result = session.query(Executions). \
While primary_key is specified twice, once for each column, there is only
ONE primary key which is a composite.
You need to use ForeignKeyConstraint at the Table level to specify a
composite foreign key.
You need to provide two lists, the local table columns, and the
corresponding foreign
I don't understand your model. Can you have multiple rows in the
Exchange table which all have the same value for Exchange.exchange?
If so, and if you want PhoneNumber to be able to point to a single one
of those rows, then it needs 2 columns to do that (one to point to
Exchange.exchange and one
On Mar 7, 2013, at 8:29 AM, jefro...@gmail.com wrote:
Hello,
We are testing the new __declare_last__ feature with 0.8. We face an issue
with the after_configured event in an application that use multiple engines.
after_configured event is triggered multiple times (by
I notice that Hybrid Attributes don't show up as mapper properties (since
they are class wide instead of mapper specific, I suppose). I couldn't
find documentation on whether I can undefer these? Or can I create a
synonym or column_property from a hybrid attribute in the mapper?
--
You
I suppose what I'm really after is a column_property (for class level) and
plain descriptor (for instance level), which is exactly what Hybrid
attributes are meant to be, but I wanted them to be part of the mapper and
undeferred in some cases.
On Thursday, March 7, 2013 11:36:37 AM UTC-5, Kent
The hybrid attribute is a Python function that invokes when it's called. So it
doesn't make sense for it to be a column property since there is no attribute
to be populated. Undeferred also doesn't make any sense because the hybrid
already calls a local in-Python function when accessed at
That makes sense,
Thanks,
Kent
On Mar 7, 2013, at 12:09 PM, Michael Bayer mike...@zzzcomputing.com wrote:
The hybrid attribute is a Python function that invokes when it's called. So
it doesn't make sense for it to be a column property since there is no
attribute to be populated.
Hello,
I'm using a column defined as:
discounts = Column(ARRAY(Discount))
Where Discount is a UserDefinedType that just passes the value through
to/from Psycopg2 (which uses a namedtuple for the discounts value):
class Discount(UserDefinedType):
SQLAlchemy type that passes through values
Can you pass along more specifics here? I don't see where this named tuple is
being created. It's true that the ARRAY type by default doesn't know how deep
it should be unwrapping arrays, if you pass the dimensions argument then it
will be fixed. But it's not clear why you didn't see this
Hi,
when I try to connect with sqlalchemy and mssql+pyodbc I get this exeption:
TypeError: The first argument to execute must be a string or unicode
query.
It works if I only use pyodbc.
E.g.
conn = pyodbc.connect('DRIVER={SQL
Server};Server=127.0.0.1;Database=BOM;UID=guest;PWD=guest')
its Python 3 related. that particular ticket refers to how bad of an
experience I have when trying to get pyodbc to run well on OSX especially in
Python 3. if things have improved, I can try working on it at least in a Linux
VM (I still have low hopes for OSX).
On Mar 7, 2013, at 1:41 PM,
On Thursday, March 7, 2013 1:40:46 PM UTC-5, Michael Bayer wrote:
Can you pass along more specifics here? I don't see where this named
tuple is being created. It's true that the ARRAY type by default doesn't
know how deep it should be unwrapping arrays, if you pass the dimensions
On Mar 7, 2013, at 2:12 PM, Jason ja...@deadtreepages.com wrote:
On Thursday, March 7, 2013 1:40:46 PM UTC-5, Michael Bayer wrote:
Can you pass along more specifics here? I don't see where this named tuple
is being created. It's true that the ARRAY type by default doesn't know how
I wanna perform a query on process_files and hereafter a update/join like
this:
SELECT files.id AS files_id, files.name AS files_name, files.directory AS
files_directory, files.active AS files_active, files.connection_id AS
files_connection_id
FROM files JOIN process_files ON files.id =
Simon,
Here is the table (not sure if the code to create a relationship table is
correct):
# Many to Many - Process x Files
process_files = Table(process_files, Base.metadata,
Column(process_id, Integer, ForeignKey(process.id)),
Column(files_id, Integer, ForeignKey(files.id))
)
The
Hi Lloyd,
Thank you! I believe this is what I was trying to figure out, although I am
having further issues now. Here's a recent pastie with my improved models,
along with the errors I'm now having, http://pastie.org/6417080
What I've done (as you can probably see) is I've used the
SQLAlchemy is broadly separated into 2 parts, core and ORM (which you can
see as the left and right-hand sides on the front page of the documentation,
http://docs.sqlalchemy.org/en/rel_0_8/)
Table objects like the one you have below are part of the Core API. Columns of
Table objects are
You have to put your ForeignKeyConstraint in the __table_args__ for the
PhoneNumber class - see
http://docs.sqlalchemy.org/en/rel_0_8/orm/extensions/declarative.html#table-configuration
for details. Something like:
class PhoneNumber(db.Model):
__tablename__ = 'phonenumbers'
Hi Simon,
Ok cool. So, I updated that, but now I'm getting the following error:
sqlalchemy.exc.NoReferencedTableError: Foreign key associated with column
'phonenumbers.exchange_exchange' could not find table 'exchange' with which
to generate a foreign key to target column 'exchange'
It looks
Thanks.
I'm gonna read the communication to watch the difference between Core and
ORM.
I changed that process_files description to Process_Files(Base): #mapping
fields
It worked!
2013/3/7 Simon King si...@simonking.org.uk
SQLAlchemy is broadly separated into 2 parts, core and ORM (which you
According to the pastie log, your table is called exchanges, not exchange,
so the target columns should be called exchanges.exchange and
exchanges.area_code_pk.
Simon
On 8 Mar 2013, at 00:27, Randall Degges rdeg...@gmail.com wrote:
Hi Simon,
Ok cool. So, I updated that, but now I'm
Simon,
Thanks man! This works perfectly, can't believe I didn't see that.
This was actually a really frustrating experience, you guys have been
extremely helpful. Thank you all so much!
Best,
-Randall
On Thu, Mar 7, 2013 at 5:15 PM, Simon King si...@simonking.org.uk wrote:
According to the
26 matches
Mail list logo