<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/">
  <channel rdf:about="http://blog.gmane.org/gmane.comp.python.sqlalchemy.user">
    <title>gmane.comp.python.sqlalchemy.user</title>
    <link>http://blog.gmane.org/gmane.comp.python.sqlalchemy.user</link>
    <description/>
    <syn:updatePeriod>hourly</syn:updatePeriod>
    <syn:updateFrequency>1</syn:updateFrequency>
    <syn:updateBase>1901-01-01T00:00+00:00</syn:updateBase>
    <items>
      <rdf:Seq>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15876"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15875"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15865"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15864"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15863"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15857"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15854"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15853"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15842"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15840"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15837"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15836"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15833"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15830"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15827"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15826"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15825"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15819"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15817"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15811"/>
      </rdf:Seq>
    </items>
    <image rdf:resource="http://gmane.org/img/gmane-25t.png"/>
    <textinput rdf:resource=""/>
  </channel>
  <image rdf:about="http://gmane.org/img/gmane-25t.png">
    <title>Gmane</title>
    <url>http://gmane.org/img/gmane-25t.png</url>
    <link>http://gmane.org</link>
  </image>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15876">
    <title>SQLAlchemy 0.5.0rc2 Released</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15876</link>
    <description>This release fixes a critical SQLite bug introduced by a backwards  
incompatible change in Pysqlite 2.5.0, which seems to be packaged in  
the latest Debian Release as well as Python 2.6.

There are additionally many bugfixes to the 0.5 series as we approach  
the final 0.5 release.

Download SQLAlchemy 0.5.0rc2 at:

http://www.sqlalchemy.org/download.html

0.5.0rc2
========
- orm
     - Fixed bug involving read/write relation()s that contain
       literal or other non-column expressions within their
       primaryjoin condition equated to a foreign key column.

     - "non-batch" mode in mapper(), a feature which allows mapper
       extension methods to be called as each instance is
       updated/inserted, now honors the insert order of the objects
       given.

     - Fixed RLock-related bug in mapper which could deadlock upon
       reentrant mapper compile() calls, something that occurs when
       using declarative constructs inside of ForeignKey objects.

     - ScopedSession.query_property now accepts a query_cls factory,
       overriding the session's configured query_cls.

     - Fixed shared state bug interfering with ScopedSession.mapper's
       ability to apply default __init__ implementations on object
       subclasses.

     - Fixed up slices on Query (i.e. query[x:y]) to work properly
       for zero length slices, slices with None on either end.
       [ticket:1177]

     - Added an example illustrating Celko's "nested sets" as a
       SQLA mapping.

     - contains_eager() with an alias argument works even when
       the alias is embedded in a SELECT, as when sent to the
       Query via query.select_from().

     - contains_eager() usage is now compatible with a Query that
       also contains a regular eager load and limit/offset, in that
       the columns are added to the Query-generated subquery.
       [ticket:1180]

     - session.execute() will execute a Sequence object passed to
       it (regression from 0.4).

     - Removed the "raiseerror" keyword argument from object_mapper()
       and class_mapper().  These functions raise in all cases
       if the given class/instance is not mapped.

     - Fixed session.transaction.commit() on a autocommit=False
       session not starting a new transaction.

     - Some adjustments to Session.identity_map's weak referencing
       behavior to reduce asynchronous GC side effects.

     - Adjustment to Session's post-flush accounting of newly
       "clean" objects to better protect against operating on
       objects as they're asynchronously gc'ed. [ticket:1182]

     - "not equals" comparisons of simple many-to-one relation
       to an instance will not drop into an EXISTS clause
       and will compare foreign key columns instead.

     - removed not-really-working use cases of comparing
       a collection to an iterable.  Use contains() to test
       for collection membership.

- sql
     - column.in_(someselect) can now be used as a columns-clause
       expression without the subquery bleeding into the FROM clause
       [ticket:1074]

- sqlite
     - Overhauled SQLite date/time bind/result processing to use
       regular expressions and format strings, rather than
       strptime/strftime, to generically support pre-1900 dates,
       dates with microseconds.  [ticket:968]

     - String's (and Unicode's, UnicodeText's, etc.) convert_unicode
       logic disabled in the sqlite dialect, to adjust for pysqlite
       2.5.0's new requirement that only Python unicode objects are
       accepted;
       http://itsystementwicklung.de/pipermail/list-pysqlite/2008-March/000018.html

- mysql
     - Temporary tables are now reflectable.

- oracle
     - Oracle will detect string-based statements which contain
       comments at the front before a SELECT as SELECT statements.
       [ticket:1187]


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

</description>
    <dc:creator>Michael Bayer</dc:creator>
    <dc:date>2008-10-12T17:59:46</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15875">
    <title>SQLAlchemy 0.4.8 released</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15875</link>
    <description>
This release fixes a critical SQLite bug introduced by a backwards  
incompatible change in Pysqlite 2.5.0, which seems to be packaged in  
the latest Debian Release as well as Python 2.6.

Download SQLAlchemy 0.4.8 at:

http://www.sqlalchemy.org/download.html

0.4.8
=====
- orm
     - Fixed bug regarding inherit_condition passed
       with "A=B" versus "B=A" leading to errors
       [ticket:1039]

     - Changes made to new, dirty and deleted
       collections in
       SessionExtension.before_flush() will take
       effect for that flush.

     - Added label() method to InstrumentedAttribute
       to establish forwards compatibility with 0.5.

- sql
     - column.in_(someselect) can now be used as
       a columns-clause expression without the subquery
       bleeding into the FROM clause [ticket:1074]

- mysql
     - Added MSMediumInteger type [ticket:1146].

- sqlite
     - Supplied a custom strftime() function which
       handles dates before 1900.  [ticket:968]

     - String's (and Unicode's, UnicodeText's, etc.)
       convert_unicode logic disabled in the sqlite dialect,
       to adjust for pysqlite 2.5.0's new requirement that
       only Python unicode objects are accepted;
       http://itsystementwicklung.de/pipermail/list-pysqlite/2008-March/000018.html

- oracle
     - has_sequence() now takes schema name into account
       [ticket:1155]
     - added BFILE to the list of reflected types
       [ticket:1121]


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


</description>
    <dc:creator>Michael Bayer</dc:creator>
    <dc:date>2008-10-12T17:57:13</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15865">
    <title>Suppressing SADeprecationWarning: 'length' is deprecated for Numeric.  Use 'scale'. for multi-version implementations of SQLAlchemy</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15865</link>
    <description>
Hi All,

According to this change set --&gt; http://www.sqlalchemy.org/trac/changeset/5054
The 'length' argument to all Numeric types has been renamed to
'scale'. 'length' is deprecated and is still accepted with a warning.

On my workstation, I have SQLAlchemy 0.5.0rc1 whereas on some servers
I have 0.4.7p1 (due to Python 2.3).

Running a script on my workstation spits out the deprecation warnings.

What would be the best way to re-write my script so it's backwards
compatible to 0.4.x and doesn't spit out the deprecation warnings in
0.5.x?

Here's an example line:
model.py:54: SADeprecationWarning: 'length' is deprecated for
Numeric.  Use 'scale'.
  schema.Column('balance', types.Numeric(precision=20, length=6),
nullable=False, default=0.000000),

I'm thinking perhaps a try block at the start of my model.py script
which tests for the SQLAlchemy version?

Thanks,
Julian

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


</description>
    <dc:creator>Julian Yap</dc:creator>
    <dc:date>2008-10-12T00:40:55</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15864">
    <title>correlated subquery w/ ORM queries</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15864</link>
    <description>
I want to do something like this:

select ticket.*, (select count(*) from ticket_changes where
ticket_changes.ticket = ticket.id) as count
from ticket

at the ORM layer.  My best stab at it was


but, .join seems to want to do an actual join in the FROM clause, and
I just want it to go into the SELECT clause as a correlated subq.  The
docs don't have any examples of a correlated subquery from the ORM so
I'm starting to think maybe this isn't possible yet.

-Jonathan

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


</description>
    <dc:creator>Jonathan Ellis</dc:creator>
    <dc:date>2008-10-12T01:41:28</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15863">
    <title>ClauseList with join?</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15863</link>
    <description>
Hi,

  I started using the .join() method on query and that' s really
powerful, with reset_joinpoint and the list of attributes setting the
path of relations. Now I'd like to being able to write join clause in
advance with respect to the moment I have the the query available , in
he same way I can write ClauseList in advance. Is there any way?

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


</description>
    <dc:creator>sandro dentella</dc:creator>
    <dc:date>2008-10-11T17:44:08</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15857">
    <title>Session does not write updated object attribute (no SQL update) (SA 0.4.6)</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15857</link>
    <description>
Hi,
I created a custom type that represents a string as list of int(elements), 
e.g.:

"2222" &lt;-&gt; [2, 2, 2, 2]

The class I created looks as follows:

class IntList(types.TypeDecorator):
    """List of integers that is represented by string in the RDB"""
    impl=String
    
    def process_bind_param(self, value, engine):
        if value == [] or value is None:
            return None
        else:
            return ''.join((str(x) for x in value))
    def process_result_value(self, value, engine):
        if value is None:
            return []
        else:
            return [int(x) for x in value]

This data type is then used in one of my tables, which is represented by an 
object.

The problem I have is that changing items in the list seems not to trigger SA, 
so that a session.flush() does not perform an update, e.g.

myobj.intlist[0] = 8

When I, however, do the following, it works:

l = list(myobj.intlist)
l[0] = 8
myobj.intlist = l

On the other hand, the following does not:

myobj.intlist[0] = 8
l = list(myobj.intlist)
myobj.intlist = l

Can please someone enlighten me why this happens, and what I can do about it?

Best Regards,
Hermann


</description>
    <dc:creator>Hermann Himmelbauer</dc:creator>
    <dc:date>2008-10-10T20:25:18</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15854">
    <title>auto incrementing</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15854</link>
    <description>
Hello,
I was wondering if anybody has a good strategy for auto incrementing fields.

I want to auto increment field called "case#" .

I have a choice of database auto increment on field "case#" or do it
myself? (correct? No other choices exists? or something in between?)

1. I would like to be able to do pick a number where we will start
doing a case#?
2. Reserver a case# for a special group which can auto increment case#
between 2,000,000-2,999,999, and add them as they come.
3. I don't want to use (system_id)

So it seems as the only way is to make my primary key:
case# - unique key, primary, not auto incrementing and let some
program manage auto incrementing.

What options do I have with sqlalchemy to manage any range of these
primary keys?
1. let db auto increment
2. Hold the next case# in a separate database table, and let my
program use it to find next case# value. How would I lock/unlock the
next case# to make there is no race condition and each case# is
taken/successfully saved.
3. Any other options?

Have people exeperienced with other strategy that is semi-automatic,
and would for for these cases.?

Thanks,
Lucas

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


</description>
    <dc:creator>Lukasz Szybalski</dc:creator>
    <dc:date>2008-10-09T20:14:27</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15853">
    <title>object_session(remote_device_object) returns noneType</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15853</link>
    <description>Morning guys,

 

When calling object_session(my_object), it returns a NoneType object so I'm
unable to call commit() and close() on the session, what does this mean?
Does it mean my object is not attached to a session?

 

My understanding is that if I did something like:

 

my_object = session.query(object).get(object_id)

 

then pass my_object around the application and wish to commit its session I
should be able to use the object_session() method to do that? Is that not
correct?

 

Cheers all,

 

Heston


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

</description>
    <dc:creator>Heston James - Cold Beans</dc:creator>
    <dc:date>2008-10-10T12:03:43</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15842">
    <title>select count group_by where ?</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15842</link>
    <description>
Hello,
Could anybody tell me what is wrong with this select statement?

Records is a mapper.

group=sqlalchemy.select([Records.TRANS_TYPE,Records.TR_DATE,func.count(Records.TR_DATE).label('date_count')],
Records.TRANS_TYPE==29).group_by([Records.TRANS_TYPE,Records.TR_DATE]).execute().fetchall()

I get system error..


Ideas?

I can't find a full example that works nowhere on the doc pages.

Thanks,
Lucas


</description>
    <dc:creator>Lukasz Szybalski</dc:creator>
    <dc:date>2008-10-10T15:15:10</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15840">
    <title>session becomes "sort of" transactional after using begin() /  commit()</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15840</link>
    <description>
Hi all,

I have a non-transactional session accessing a MySQL database with
InnoDB tables (SA 0.4.7). It's created via


For some queries, I use begin() / commit() for explicit transactions.
However, after commit()ing, SQLAlchemy wraps all subsequent operations
on the same session in BEGIN/COMMIT statements (as observable in
MySQL's SQL log), even though I did not call begin() again! Not even
close() changes this behavior. Is this intended and if so, how can I
make it untransactional again?

Thanks, Simon

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


</description>
    <dc:creator>Simon</dc:creator>
    <dc:date>2008-10-10T14:52:35</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15837">
    <title>SA 0.5 rc1 - Mysql Unicode(1) decode error</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15837</link>
    <description>Hi

 

I needed a Unicode(1) Column in one of my tables.

 

It was translated into a char(1) column in MySQL.

 

When querying the table, I get a:  AttributeError: 'Set' object has no
attribute 'decode'

 

Which disappears if I make the column a Unicode(2), so there might be a
small bug in the MySQL code translating Unicode(1) to char(1) ....???

 

Martijn

 

________________________________

Van: sqlalchemy&lt; at &gt;googlegroups.com [mailto:sqlalchemy&lt; at &gt;googlegroups.com]
Namens Heston James - Cold Beans
Verzonden: Thursday, October 09, 2008 5:33 PM
Aan: sqlalchemy&lt; at &gt;googlegroups.com
Onderwerp: [sqlalchemy] Can't connect to local MySQL server

 

Hello Guys,

 

I'm receiving errors in my application on a fairly regular basis now and
I'm not sure how to begin solving it.

 

Please find attached a backtrace for the error. It seems that its
struggling to connect to the MySQL server, however I get this after the
application has been running and querying the database for some time.

 

Any ideas what might be causing this? I'd appreciate your thoughts. The
code which throws the error is a very simple query(some_object).get(id)

 

Cheers all,

 

Heston





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

</description>
    <dc:creator>Martijn Moeling</dc:creator>
    <dc:date>2008-10-10T12:25:07</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15836">
    <title>avoiding locks with SA</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15836</link>
    <description>
Let's say you have two concurrent processes where each might increment
some integer field in some table row.
If you query first and the increment in memory and then update, you
need to query with_lockmode('update') to avoid the case where both
processes read the same value and the do the same increment.
A simpler method is to use SQL s.a. set field = field+1.

Q: How do you generate such SQL with SA ?

Is there a better method to do it?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to sqlalchemy&lt; at &gt;googlegroups.com
To unsubscribe from this group, send email to sqlalchemy+unsubscribe&lt; at &gt;googlegroups.com
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---


</description>
    <dc:creator>Moshe C.</dc:creator>
    <dc:date>2008-10-10T00:40:21</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15833">
    <title>Copying SQLA objects from one DB to another</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15833</link>
    <description>
Hi,

I was wondering if there is an easy way to copy SQLA objects from one
DB to another. I've poked around and found this thread:
http://groups.google.com/group/sqlalchemy/browse_thread/thread/c1bd8cfe862441d6
but my application is different so I thought I'd post.

Basically, I have a database of many SQLA objects, call them Users.
Each user has foreign key references to addresses, groups, etc. I want
to create a new test database which contains a small subset of Users,
but pulls any addresses, or groups over as well and creates rows in
those tables to satisfy the foreign key constraints. I don't care if
primary keys change (as long as the constraints are satisfied).

To copy over the first 10 users I naively tried doing something along
the lines of:

sess1 = ProductionDBSession()
sess2 = TestDBSession()

users = sess1.query(User).filter(User.id&lt;10)
for user in users:
    sess2.add(user)
    sess2.commit()

Of course this doesn't work because user is in the persisted state
within sess1.

What I was hoping though, was that the user.address_list and
user.group_list attributes would also be copied over by creating rows
in the address and group tables as well as the user table and setting
the proper foreign key relationships.

I'm prepared to write a more custom script that copies individual
objects and sets up the foreign key relationships by hand, but if
there was something like this I could do to make it a simpler process,
that would be great.

Thanks!

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


</description>
    <dc:creator>Sam Magister</dc:creator>
    <dc:date>2008-10-10T00:55:56</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15830">
    <title>ratio on multiple tables</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15830</link>
    <description>
I have some tables with financial data -- one table has price data on
a given date and another data has fundamental data on a given report
date.  I am wondering if it is possible to create another object that
is a ratio on a join between values in the two tables, eg in pseudo
code

  # divide the current price by the most recent sales figure
  price_sales = price_table.price / fundamental_table.sales where
fundamental_table.reportdate&lt;=price_table.date order by
fundamental_table.reportdate limit 1

I would also like this price_sales to be an attribute that is itself
queryable, eg, so I can express

  select all where ratio_data.price_sales&lt;2 and and price_data.price&gt;5

I am a bit of a sqlalchemy newbie -- I have written the price data and
fundamental tables below.  If there is a way  to express the above
ratio data as a handy sqlalchemy map, I'd appreciate any suggestions

Version and table example code below


In [81]: sa.__version__
Out[81]: '0.5.0beta4'

import datetime
import sqlalchemy as sa
import sqlalchemy.orm as orm
from sqlalchemy.ext.declarative import declarative_base
engine = sa.create_engine("mysql://johnh:research123&lt; at &gt;userver132/trdlnksec")
Base = declarative_base(bind=engine)

class PriceData(Base):
    __tablename__ = 'price_data'

    ticker = sa.Column(sa.String(12), primary_key=True)
    date = sa.Column(sa.Date, primary_key=True)
    price = sa.Column(sa.FLOAT)

    def __init__(self, ticker, date, price, volume):
        self.ticker = ticker
        self.date = date
        self.price = price

    def __repr__(self):
        return "PriceData('%s', %r, %r')"%(self.ticker, self.date, self.price)

class FundamentalData(Base):
    __tablename__ = 'fundamentals'

    ticker = sa.Column(sa.String(12), primary_key=True)
    reportdate = sa.Column(sa.Date, primary_key=True)
    sales = sa.Column(sa.FLOAT)
    income = sa.Column(sa.FLOAT)

    def __init__(self, ticker, reportdate, sales, income):
        self.ticker = ticker
        self.reportdate = reportdate
        self.sales = sales
        self.income = income

    def __repr__(self):
        return "FundamentalData('%s', %r, %r, %r')"%(self.ticker,
self.reportdate, self.sales, self.income)




if __name__=='__main__':

    Session = orm.sessionmaker()
    session = Session(bind=engine)
    Base.metadata.drop_all()
    Base.metadata.create_all()


    i1 = PriceData('IBM', datetime.date(2008,1,1), 100, 1000.)
    i2 = PriceData('IBM', datetime.date(2008,1,2), 101, 2000.)
    i3 = PriceData('IBM', datetime.date(2008,1,3), 102, 2000.)

    q4 = FundamentalData('IBM', datetime.date(2007,12,1), 30000.,  3000.)
    q3 = FundamentalData('IBM', datetime.date(2007,9,1), 20000.,  2000.)
    q2 = FundamentalData('IBM', datetime.date(2007,6,1), 10000.,  1000.)
    q1 = FundamentalData('IBM', datetime.date(2007,3,1), 10001.,  1001.)


    session.add(i1)
    session.add(i2)
    session.add(i3)
    session.add(q1)
    session.add(q2)
    session.add(q3)
    session.add(q4)


    session.commit()

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


</description>
    <dc:creator>John Hunter</dc:creator>
    <dc:date>2008-10-09T19:28:30</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15827">
    <title>Configuring sqlalchemy pool</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15827</link>
    <description>
Hi All,

I'm having a problem with my pool in that it's not enough connections
and I need to modify them.  The default settings are:

max_overflow=10
pool_size=5
timeout=30

I want to change these values, and when looking through the
documentation I found this: http://www.sqlalchemy.org/docs/04/pooling.html

This is for 0.4 however, and I'm using 0.5.  Lastly, in the example
they use on this page it creates a connection to create a QueuePool

Example from website:

import sqlalchemy.pool as pool
import psycopg2

def getconn():
    c = psycopg2.connect(username='ed', host='127.0.0.1',
dbname='test')
    # execute an initialization function on the connection before
returning
    c.cursor.execute("setup_encodings()")
    return c

p = pool.QueuePool(getconn, max_overflow=10, pool_size=5,
use_threadlocal=True)

What exactly is getconn?  Do I need it?  All I want to do is create my
own pool settings and send them through my engine_from_config
commands.

Any ideas?

Thanks for your help!

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


</description>
    <dc:creator>ashok</dc:creator>
    <dc:date>2008-10-09T17:27:33</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15826">
    <title>infinity with mysql backend</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15826</link>
    <description>
I have a sqlalchemy table with a float column, and I would like to be
able to store +/- infinity.  I am using numpy, and have access to
np.inf.  However, if I try and store this value, I get

  OperationalError: (OperationalError) (1054, "Unknown column
'Infinity' in 'field list'")

Is there a way to store infinity using sqlalchemy with a mysql
backend?

In [128]: sa.__version__
Out[128]: '0.5.0beta4'

johnh&lt; at &gt;flag:~&gt; mysql --version
mysql  Ver 12.22 Distrib 4.0.24, for pc-solaris2.10 (i386)

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


</description>
    <dc:creator>jdh2358&lt; at &gt;gmail.com</dc:creator>
    <dc:date>2008-10-09T16:22:03</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15825">
    <title>Can't connect to local MySQL server</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15825</link>
    <description>  File "/var/lib/python-support/python2.5/sqlalchemy/orm/query.py", line 414, in get
    return self._get(key, ident)
  File "/var/lib/python-support/python2.5/sqlalchemy/orm/query.py", line 1211, in _get
    return q.all()[0]
  File "/var/lib/python-support/python2.5/sqlalchemy/orm/query.py", line 985, in all
    return list(self)
  File "/var/lib/python-support/python2.5/sqlalchemy/orm/query.py", line 1073, in __iter__
    return self._execute_and_instances(context)
  File "/var/lib/python-support/python2.5/sqlalchemy/orm/query.py", line 1076, in _execute_and_instances
    result = self.session.execute(querycontext.statement, params=self._params, mapper=self._mapper_zero_or_none(), _state=self._refresh_state)
  File "/var/lib/python-support/python2.5/sqlalchemy/orm/session.py", line 750, in execute
    return self.__connection(engine, close_with_result=True).execute(
  File "/var/lib/python-support/python2.5/sqlalchemy/orm/session.py", line 717, in __connection
    return self.transaction._connection_for_bind(engine)
  File "/var/lib/python-support/python2.5/sqlalchemy/orm/session.py", line 326, in _connection_for_bind
    conn = bind.contextual_connect()
  File "/var/lib/python-support/python2.5/sqlalchemy/engine/base.py", line 1247, in contextual_connect
    return self.Connection(self, self.pool.connect(), close_with_result=close_with_result, **kwargs)
  File "/var/lib/python-support/python2.5/sqlalchemy/pool.py", line 161, in connect
    return _ConnectionFairy(self).checkout()
  File "/var/lib/python-support/python2.5/sqlalchemy/pool.py", line 321, in __init__
    rec = self._connection_record = pool.get()
  File "/var/lib/python-support/python2.5/sqlalchemy/pool.py", line 180, in get
    return self.do_get()
  File "/var/lib/python-support/python2.5/sqlalchemy/pool.py", line 618, in do_get
    con = self.create_connection()
  File "/var/lib/python-support/python2.5/sqlalchemy/pool.py", line 141, in create_connection
    return _ConnectionRecord(self)
  File "/var/lib/python-support/python2.5/sqlalchemy/pool.py", line 217, in __init__
    self.connection = self.__connect()
  File "/var/lib/python-support/python2.5/sqlalchemy/pool.py", line 280, in __connect
    connection = self.__pool._creator()
  File "/var/lib/python-support/python2.5/sqlalchemy/engine/strategies.py", line 80, in connect
    raise exc.DBAPIError.instance(None, None, e)
OperationalError: (OperationalError) (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)") None None</description>
    <dc:creator>Heston James - Cold Beans</dc:creator>
    <dc:date>2008-10-09T15:32:52</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15819">
    <title>subselect and auto-correlate issue (0.5rc1)</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15819</link>
    <description>
I have the following code:

        tags = [u"tag1", u"tag2"]
        tag_count = len(tags)

        inner_q = select([shiptag_table.c.shipid])
        inner_w = inner_q.where(
            and_(shiptag_table.c.tagid == Tag.id,Tag.name.in_(tags))
        ).group_by(shiptag_table.c.shipid).having(func.count(shiptag_table.c.shipid)
== tag_count)

        outer_q = select([Tag.id, Tag.name,
func.count(shiptag_table.c.shipid)])
        outer_w = outer_q.where(
            and_(shiptag_table.c.shipid.in_(inner_w),
            not_(Tag.name.in_(tags)),
            Tag.id == shiptag_table.c.tagid)
        ).group_by(shiptag_table.c.tagid)

        related_tags = meta.Session.execute(outer_w).fetchall()
        return related_tags

If I try to execute as is, I get the following error:
InvalidRequestError: Select statement 'SELECT shiptag.shipid
FROM shiptag, tag
WHERE shiptag.tagid = tag.id AND tag.name IN (:name_1) GROUP BY
shiptag.shipid
HAVING count(shiptag.shipid) = :count_1' returned no FROM clauses due
to auto-correlation; specify c
orrelate(&lt;tables&gt;) to control correlation manually.

The inner_w select is claiming to not have any FROM clauses, though
they are clearly listed in the debug?
If I run the inner_w separate, not as a subselect, then feed the
results in to the in_ of outer_w it works.
I figure I have to be missing something obvious?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to sqlalchemy&lt; at &gt;googlegroups.com
To unsubscribe from this group, send email to sqlalchemy+unsubscribe&lt; at &gt;googlegroups.com
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---


</description>
    <dc:creator>Wayne Witzel</dc:creator>
    <dc:date>2008-10-09T14:20:51</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15817">
    <title>MapperExtension.methods property</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15817</link>
    <description>
Is there any reason why I would expect after_update to be called but
before_update to never be called?

What is responsible for creating the .methods property on the
extension?  I'm creating it by hand so that I can manually set the
extension property of a mapper after the fact.  But there's nothing in
the documentation to suggest that this property is necessary for
correct behavior.

I would humbly suggest that this ought to be a property on
MapperExtension that creates that list if it doesn't already exist.
Whoever is creating it now is difficult enough to track down that I
gave up after about 30 minutes of tracing code.

Regards,
Ross

class MyExtension(MapperExtension):

    def __init__(self):
        # KLUDGE rab: added to avert error in sqlalchemy.orm.query
"FulltextUpdate has no attribute 'methods'"
        MapperExtension.__init__(self)
        self.methods = ('after_insert', 'after_update',
'before_delete')

    def after_insert(self, mapper, connection, instance):
        log.debug('after_insert() ran')
        return EXT_CONTINUE;

    def after_update(self, mapper, connection, instance):
        log.debug('before_update() ran')
        return EXT_CONTINUE;

    def before_delete(self, mapper, connection, instance):
        log.debug('before_delete() ran')
        return EXT_CONTINUE;

SomeClass.mapper.extension = MyExtension()

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


</description>
    <dc:creator>rabagley</dc:creator>
    <dc:date>2008-10-09T07:06:54</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15811">
    <title>mysql utf8 encoding problem</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15811</link>
    <description>
Hi,

Firstly - I'm hugely impressed with SQLAlchemy - it's really helped me
a lot with my new project.

I'm having problems storing international characters in mysql using
SQLAlchemy. For example:

  école—school

looks like this in mysql:

  Ã©coleâ€”school

I'm using the following engine call:

  engine = create_engine(config.db, encoding='utf-8')

and using Unicode as the column type:

  Column('content',       UnicodeText),

and utf8 for the table:

  mysql_charset='utf8'

I'm pretty sure all my mySQL options are set to utf8. This looks
really similar to a 'double encoding' issue I found while searching
the group, but it seems that was fixed in python-mysql 1.2.2, which is
what I'm using.

Any help would be much appreciated.

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


</description>
    <dc:creator>joelanman</dc:creator>
    <dc:date>2008-10-08T23:59:03</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15808">
    <title>insert NULL value</title>
    <link>http://comments.gmane.org/gmane.comp.python.sqlalchemy.user/15808</link>
    <description>
Hi all,

I don't know how to insert a NULL value in a mysql table...

Here is my code:
######
table = Table("table", metadataConfig, autoload=True)
i = table.insert()
i.execute({param1:'HIHIIH',param2:Null})
######

I tried to replace Null by None, but in Mysql, the result is None...

Is the a sqlalchemy contant defined for Null?

thanks in advance

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


</description>
    <dc:creator>menuge</dc:creator>
    <dc:date>2008-10-08T14:58:50</dc:date>
  </item>
  <textinput rdf:about="http://search.gmane.org/?group=$group=gmane.comp.python.sqlalchemy.user">
    <title>Search Engine</title>
    <description>Search the mailing list at Gmane</description>
    <name>query</name>
    <link>http://search.gmane.org/?group=$group=gmane.comp.python.sqlalchemy.user</link>
  </textinput>
</rdf:RDF>
