Eric Abrahamsen | 17 May 16:51
Picon

filtering by datetime elements


Hi there,

I'm new to this, so please be patient if I'm a little slow... I'm  
trying to filter Article objects by a datetime field ('pubdate'), and  
expected that I would be able to do something like this:

arts = sess.query(Article).filter(and_(Article.pubdate.year==year,  
Article.pubdate.month==month, Article.id==id)).one()

This gives me:
AttributeError: 'InstrumentedAttribute' object has no attribute 'year'

Apparently methods on attributes are reserved for sqlalchemy  
internals, and I'm not working with a straight Python object, as I'd  
thought. That makes sense, but can anyone suggest a simple substitute  
for what I'm trying to do here?

Thanks very much,
Eric

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to sqlalchemy <at> googlegroups.com
To unsubscribe from this group, send email to sqlalchemy-unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Allen Bierbaum | 16 May 21:48
Picon

Is inserting new data with column_mapped_collection inconsistent?


I have just started using column_mapped_collections.
(http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_relation_collections_dictcollections

I must say, these are very powerful and extremely nice when reading
data.  But I have run into one thing that seems confusing when it
comes to creating new objects in a session.  Namely, it is possible to
add data to the mapped dictionary in such a way that the data
structure is inconsistent and not what it would be when reading the
same data back.

Using the example from the documentation as a start:

mapper(Item, items_table, properties={
    'notes': relation(Note,
collection_class=column_mapped_collection(notes_table.c.keyword)),
})

# ...
item = Item()
item.notes['color'] = Note('color', 'blue')   # Set keyword attribute to 'color'
print item.notes['color']

Everything is good here, but what if I did it this way instead....

item.notes['not-color'] = Note('color', 'blue')

This last line is the problem because it has inserted a link to a new
Note that has a keyword of
'color' but is showing up in the dictionary as 'not-color'.  If we
(Continue reading)

Jim R. Wilson | 16 May 21:22
Picon

SQLAlchemy experts wanted


Hi all,

SQLAlchemy is a great project and a growing niche.  As it becomes even
more popular, there will be increasing demand for experts in the
field.

I am compiling a contact list of SQLAlchemy experts who may be
interested in opportunities under the right circumstances.  I am not a
recruiter - I'm a regular developer who sometimes gets asked for
referrals when I'm not personally available.

If you'd like to be on my shortlist of go-to experts, please contact
me off-list at: wilson.jim.r <at> gmail.com

Please be prepared to show your expertise by any of the following:
 * Committer status or patches accepted
 * Commit access to another open source project which uses SQLAlchemy
 * Bugs reported which were either resolved or are still open (real
bugs)
 * Articles / blog entries written about SQLAlchemy concepts or
development
 * Speaking engagements or user groups at which you've presented
 * Significant contributions to documentation
 * Other? (I'm sure I didn't think of everything)

I'll be happy to answer any questions, and I look forward to hearing
from you!

-- Jim R. Wilson (jimbojw)
(Continue reading)

Mike | 16 May 17:57
Picon

Using SQLAlchemy with Plone/Zope


Hi,

We are using SQLAlchemy 4.X in Zope using SQLAlchemyDA, found here:

http://opensource.zopyx.com/projects/SQLAlchemyDA

This uses SA 0.4.0. We are connecting to MS SQL 2000. While this works
in Zope for normal SQL commands, if we try to execute a stored
procedure, we get the following traceback:

[Traceback (most recent call last):
  File "sqltest.py", line 14, in ?
    print cur.fetchall()
  File "/opt/Plone-2.5/Python-2.4.3/lib/python2.4/site-packages/
SQLAlchemy-0.4.0-py2.4.egg/sqlalchemy/engine/base.py", line 1231, in
__repr__
    return repr(tuple(self))
  File "/opt/Plone-2.5/Python-2.4.3/lib/python2.4/site-packages/
SQLAlchemy-0.4.0-py2.4.egg/sqlalchemy/engine/base.py", line 1223, in
__iter__
    yield self.__parent._get_col(self.__row, i)
  File "/opt/Plone-2.5/Python-2.4.3/lib/python2.4/site-packages/
SQLAlchemy-0.4.0-py2.4.egg/sqlalchemy/engine/base.py", line 1468, in
_get_col
    rec = self._key_cache[key]
AttributeError: 'ResultProxy' object has no attribute '_key_cache'

I'm not sure how to go about troubleshooting this. Would upgrading it
to SQLAlchemy 0.4.5 fix it? Any hints would be appreciated.
(Continue reading)

Michael Hipp | 16 May 15:37
Favicon

"Opportunistic locking" or "edit sequence"


Hello, new to SQLAlchemy. A question...

Does SA implement what is sometimes referred to as opportunistic locking or 
sequence locking? This is intended to prevent near simultaneous but 
incompatible UPDATESs of the same record in the database by two different clients.

Some databases implement this by using a field like 'edit_sequence' which is an 
incrementing sequence where the value in the db must match that in the UPDATE.

Does SA have such a feature or something like it?

Thanks,
Michael Hipp
Heber Springs, Arkansas, USA

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to sqlalchemy <at> googlegroups.com
To unsubscribe from this group, send email to sqlalchemy-unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Jim Steil | 16 May 15:11

Access to AS/400 data


Hi:

Can anyone tell me if it is possible to access data on an AS/400 through 
SQLAlchemy?

    -Jim

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to sqlalchemy <at> googlegroups.com
To unsubscribe from this group, send email to sqlalchemy-unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Carlos Hanson | 16 May 00:41
Picon

declarative_base and UNIQUE Constraint


Greetings,

I just started playing with declarative_base.  I have one table on
which I would like to have a unique contraint on two columns.  Is this
possible using declarative?

--

-- 
Carlos Hanson

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to sqlalchemy <at> googlegroups.com
To unsubscribe from this group, send email to sqlalchemy-unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

sbhatt | 15 May 21:50
Picon

SA with ORACLE connect


Hi All,

I want to write a query in SA which uses ORACLE 'connect' along with
joins on other table.
The query will be:-
SELECT grouprelation.grouprelationid AS grouprelation_grouprelationid,
grouprelation.parentgroupid AS grouprelation_parentgroupid,
grouprelation.childgroupid AS grouprelation_childgroupid FROM
grouprelation, grouptable CONNECT BY childgroupid = PRIOR
parentgroupid START WITH childgroupid = 91 AND
grouprelation.parentgroupid = grouptable.groupid AND
grouptable.wfstatus != 'I'

I tried writing it in SA as following:-

connectstring = "connect by childgroupid = prior parentgroupid start
with childgroupid = 91"

query =
session.query(GroupRelation).filter(sql.and_(GroupRelation.c.parentgroupid
== GroupTable.c.groupid, GroupTable.c.wfstatus != 'I', connectstring))

compiles to

SELECT grouprelation.grouprelationid AS grouprelation_grouprelationid,
grouprelation.parentgroupid AS grouprelation_parentgroupid,
grouprelation.childgroupid AS grouprelation_childgroupid FROM
grouprelation, grouptable WHERE grouprelation.parentgroupid =
grouptable.groupid AND grouptable.wfstatus != 'I' AND connect by
(Continue reading)

Chris Guin | 15 May 21:20
Picon

allow_column_override

My goal is to have a one-to-many relation defined using the same name as the foreign key column underneath.  So that, if my "Detection" table has a foreignkey column named "sensor," the following mappers should work, I think:

mapper(Sensor, sensor)
detectionmapper = mapper(Detection, detection, allow_column_override= True , properties={
    'sensor' : relation(Sensor),
})

I'm getting the following exception, however, when I actually create a Detection with a Sensor and try to flush the session:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\scoping.py", line 98, in do
    return getattr(self.registry(), name)(*args, **kwargs)
  File "c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\session.py", line 757, in flush
    self.uow.flush(self, objects)
  File "c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\unitofwork.py", line 233, in flush
    flush_context.execute()
  File "c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\unitofwork.py", line 445, in execute
    UOWExecutor().execute(self, tasks)
  File "c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\unitofwork.py", line 930, in execute
    self.execute_save_steps(trans, task)
  File "c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\unitofwork.py", line 948, in execute_save_steps
    self.execute_dependencies(trans, task, False)
  File "c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\unitofwork.py", line 959, in execute_dependencies
    self.execute_dependency(trans, dep, False)
  File "c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\unitofwork.py", line 942, in execute_dependency
    dep.execute(trans, isdelete)
  File "c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\unitofwork.py", line 895, in execute
    self.processor.process_dependencies(self.targettask, [elem.state for elem in self.targettask.polymorphic_tosave_elements if elem
.state is not None], trans, delete=False)
  File "c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\dependency.py", line 332, in process_dependencies
    self._synchronize(state, child, None, False, uowcommit)
  File "c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\dependency.py", line 374, in _synchronize
    sync.populate(child, self.mapper, state, self.parent, self.prop.synchronize_pairs)
  File "c:\python25\lib\site-packages\SQLAlchemy-0.4.5-py2.5.egg\sqlalchemy\orm\sync.py", line 27, in populate
    self._raise_col_to_prop(True, source_mapper, l, dest_mapper, r)
NameError: global name 'self' is not defined


I am still using SQLAlchemy 0.4.5.

Thanks for any help!
Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to sqlalchemy <at> googlegroups.com
To unsubscribe from this group, send email to sqlalchemy-unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Craig Swank | 15 May 18:55
Picon

processing.Process and sqlalchemy


Hello,
I am playing around with loading data into a database using subclasses
of processing.Process so that data files can be sent to a server.  I
would like to have the server fire off a process that takes care of
parsing the data file and loading the data into a data.

When I run some tests that start up a few of theses processes at once,
I run into OperationalErrors due to the database being locked by one
of the other process.

Does anyone have suggestions on how to handle this?  I am pretty new
to sqlalchemy, so please forgive me if I'm missing something basic.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to sqlalchemy <at> googlegroups.com
To unsubscribe from this group, send email to sqlalchemy-unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Nick Murphy | 15 May 18:51
Picon

Default collection class for unordered relations


Hello Group,

After looking over the 0.5 migration notes and seeing that implicit
ordering is to be removed, it seems to me that it might make sense to
change the default collection class for unordered relations from a
list to a multiset.  This would reinforce that unless order_by is
specified, one cannot rely on a collection having a particular order.
I could see this as helpful in preventing bugs when switching between
databases (e.g. from MySQL to PostgreSQL) with different default
ordering behaviors.

Regards,
Nick
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to sqlalchemy <at> googlegroups.com
To unsubscribe from this group, send email to sqlalchemy-unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---


Gmane