Harish K Vishwanath | 20 Aug 11:38

Code working on SQLA 0.4.6 is breaking on SQLA 0.5beta3

Hello,

I was using elixir 0.5.2 (SQL Alchemy 0.4.6) on Py 2.4.

All my model objects inherits from Entity as well as another baseobject specific to our application.

class User(elixir.Entity, application.baseobject):
...
...

It used to work fine.

Today I upgraded to SQLA 0.5 beta3 and elixir 0.6.1. The same code doesn't work anymore.


  File "c:\Python24\lib\site-
packages\elixir-0.6.1-py2.4.egg\elixir\entity.py",
line 816, in setup_entities
  File "c:\Python24\lib\site-packages\elixir-0.6.1-py2.4.egg\elixir\entity.py",
line 409, in setup_mapper
  File "c:\python24\lib\site-packages\SQLAlchemy-0.5.0beta3-py2.4.egg\sqlalchemy
\orm\__init__.py", line 623, in mapper
    return Mapper(class_, local_table, *args, **params)
  File "c:\python24\lib\site-packages\SQLAlchemy-0.5.0beta3-py2.4.egg\sqlalchemy
\orm\mapper.py", line 196, in __init__
    self.__compile_class()
  File "c:\python24\lib\site-packages\SQLAlchemy-0.5.0beta3-py2.4.egg\sqlalchemy
\orm\mapper.py", line 844, in __compile_class
    manager = attributes.create_manager_for_cls(self.class_)
  File "c:\python24\lib\site-packages\SQLAlchemy-0.5.0beta3-py2.4.egg\sqlalchemy
\orm\attributes.py", line 1498, in create_manager_for_cls
    existing_factories = collect_management_factories_for(class_)
  File "c:\python24\lib\site-packages\SQLAlchemy-0.5.0beta3-py2.4.egg\sqlalchemy
\orm\attributes.py", line 1604, in collect_management_factories_for
    hierarchy = util.class_hierarchy(cls)
  File "c:\python24\lib\site-packages\SQLAlchemy-0.5.0beta3-py2.4.egg\sqlalchemy
\util.py", line 408, in class_hierarchy
    for s in [_ for _ in c.__subclasses__() if _ not in hier]:
AttributeError: class IRObject has no attribute '__subclasses__'

IRObject is our app specific base class.

Any ideas?
Thanks,
Harish

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

naktinis | 19 Aug 21:46

error while accessing row in create_instance


In MapperExtension's method create_instance(self, mapper,
selectcontext, row, class_) I try to call row.has_key('some_key') but
I get:

AttributeError: 'str' object has no attribute 'proxy_set'

This is in version 0.4.6. It worked fine in 0.4.2p3.

What could be the problem?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Jose Galvez | 19 Aug 20:42

declarative


What is the proposed stability of declarative functions which I guess 
are pretty new.  From what I've read so far I really like it and was 
thinking of using it, but was just wondering what the long turn outlook 
for it looked like?  After doing some reading on the new release of 
Elixir, Elixir looks like a mich simplier and more feature complete then 
declarative, but It does not look like Elixir works with a legacy 
databse (but I'm still looking into that) so I was wondering about 
declarative's long term stability. 

Thanks Jose

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Gerrat | 19 Aug 19:55

Creating Oracle Triggers on Table Create


We have an oracle database, and all of our tables have auto-generating
id's on the primary key via a trigger that looks like :
-----------------
CREATE OR REPLACE TRIGGER "SCHEMA".some_table_rid
BEFORE INSERT OR UPDATE OF rid ON some_table
FOR EACH ROW
BEGIN
  IF UPDATING
  THEN
    :new.rid := :old.rid;
  END IF;
  IF INSERTING
  THEN
    IF :new.rid = 0
  THEN
      SELECT some_table_rid.NEXTVAL INTO :new.rid FROM dual;
    ELSE
      DECLARE
        num1 number(12);
      BEGIN
        SELECT last_number INTO num1 FROM USER_SEQUENCES WHERE
SEQUENCE_NAME = 'SOME_TABLE_RID';
        IF num1 <= :new.rid
        THEN
          LOOP
            SELECT some_table_rid.NEXTVAL INTO num1 FROM dual;
            EXIT WHEN num1 >= :new.rid;
          END LOOP;
        END IF;
      END;
    END IF;
  END IF;
END;
-----------------
This allows any external tool (like SQL Alchemy) to control primary
key generation via the sequence, but still allows the next id to be
inserted automatically by just inserting a 0 into the table for the
primary key

I'd like a similiar trigger created on every table create that
included a Sequence as part of a primary_key col.

Is there a way to easily hook into the table creation mechanism so
that whenever a Sequence was specified as part of a Column definition,
a similiar trigger could be inserted (substituting some names
obviously)?  I know I can manually issue the DDL after-the-fact for
each table create, but would prefer it be more implicit.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

DateTime Column as Python time tuple.

Hello Guys,

 

I’m looking to send an object from SQLAlchemy across a ZSI web service as a complex type. To do this ZSI requires that datetime’s in the objects be in Python Time Tuples as documented in the ‘time’ module.

 

It looks as if by default SQLAlchemy uses datetime.datetime objects for columns defined like:

 

created = Column(DateTime, default=func.now())

 

Is there any way in which I can configure SQLAlchemy to return me time tuples instead? Or perhaps a cheeky way I can convert from datetime.datetime to time.time?

 

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 <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
-~----------~----~----~----~------~----~------~--~---

Tom | 19 Aug 02:38

Self-referential mapping with "Root" ids/access


I am trying to build a self-referential mapper like the basic_tree
example, but would like to be able to access the root of any given
TreeNode, much like the now depreciated and tricky byroot_tree.py.
Before you tell me just to use the byroot_tree, zzzeek has already
told me to work with eager loading and the byroot_tree has some issues
loading currently.

http://svn.sqlalchemy.org/sqlalchemy/tags/rel_0_5beta3/examples/adjacencytree/basic_tree.py
http://svn.sqlalchemy.org/sqlalchemy/tags/rel_0_5beta3/examples/adjacencytree/byroot_tree.py

So here is my issue: whenever I try to modify basic_tree to keep track
of root_id's and map the root property I run into the following
problem:

   "ArgumentError: Could not determine join condition between parent/
child tables on relation Node.children.
   Specify a 'primaryjoin' expression.  If this is a many-to-many
relation, 'secondaryjoin' is needed as well."

Note, this is even when I use a primaryjoin similar to the byroot
example:

    root=relation(Node, primaryjoin=trees.c.root_id==trees.c.id,
                  remote_side=trees.c.id, lazy=None)

Can anyone help me convert the eager loading example to allow root
access? This is particularly important because every time I load a
TreeNode, I want to be able to access the root, and I also want to be
able to retrieve all the TreeNodes for a given root_id.

Thank you,
Tom

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Ally | 18 Aug 18:27

Multiple Foreign Keys


Hi all,

I’m fairly new to DBs and SQA and I’m having a few issues with
multiple foreign keys. Essentially, I have a “Character” table with
Character IDs and their associated name, and a Stats table, with
containing data about various events, with two separate columns both
with FKs to the Character ID table.

These tables are stored in on my HDD relected at runtime, using the
Table('Character', meta, autoload=True) format. My problems arise
whenever I try and join these tables, I keep getting an error similar
to this:

“Can't determine join between Stats and 'Character'; tables have more
than one foreign key constraint relationship between them. Please
specify the 'onclause' of this join explicitly.”

Fair enough, but when I try to do this, along the lines of:

s =
join(Stats,Character,DeathKill.c.OBj1_uid==Character.c.character_uid)

I get:

“sqlalchemy.exc.ArgumentError: Not an executable clause: [DeathKill]
JOIN [Character] ON [DeathKill].killer_uid =
[Character].character_uid”

Any suggestions or pointers would be greatly appreciated! Sorry I
can’t post more code just now as I not near my work PC!

Thanks,

Ally

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Brad Wells | 18 Aug 17:10

AttributeError: 'property' object has no attribute 'impl'


I receive the following error with SA 0.4.7p1 and the latest 0.4 svn
revision.

"AttributeError: 'property' object has no attribute 'impl'"

Mappers
======

mapper(TransactionType, transaction_types)

    transactions_mapper = mapper(Transaction, transactions,
order_by=transactions.c.date,
        extension=[HistoryMapperExtension(),
TransactionDateMapperExtension()],
        polymorphic_on=transactions.c.transaction_type_id,
polymorphic_identity=0,
        exclude_properties=['number', 'address', 'shipping',
'handling', 'purchase_order',
                            'contact_note', 'notes', 'valid_until'],
        properties={
            '_voided_at': transactions.c.voided_at,
            '_date': transactions.c.date,
            'method': relation(PaymentMethodType,
backref='transactions'),
            'transaction_type': relation(TransactionType,
backref='transactions'),
            'created_by_id': transactions.c.created_by,
            'updated_by_id': transactions.c.updated_by,
            'created_by': relation(Contact,
primaryjoin=transactions.c.created_by==contacts.c.id),
            'updated_by': relation(Contact,
primaryjoin=transactions.c.updated_by==contacts.c.id),
    })

    mapper(Cost, inherits=transactions_mapper, polymorphic_identity=1,
properties={
        'line_items': relation(LineItem, backref='cost',
cascade='delete')
    })
    mapper(Payment, inherits=transactions_mapper,
polymorphic_identity=2)

    mapper(Receipt, inherits=transactions_mapper,
polymorphic_identity=4)
    mapper(Adjustment, inherits=transactions_mapper,
polymorphic_identity=5)

    abstract_sales_mapper = mapper(AbstractSale,
inherits=transactions_mapper,

polymorphic_on=transactions.c.transaction_type_id,
                                   properties={
        'number': transactions.c.number,
        'address': transactions.c.address,
        'shipping': transactions.c.shipping,
        'handling': transactions.c.handling,
        'purchase_order': transactions.c.purchase_order,
        'contact_note': transactions.c.contact_note,
        'notes': transactions.c.notes,
        'payment_terms': relation(PaymentTerm,
backref='abstract_sales'),
        'line_items': relation(LineItem, backref='sale',
cascade='delete', order_by=line_items.c.position)
    })

    mapper(Sale, inherits=abstract_sales_mapper,
polymorphic_identity=3)

    mapper(Quote, inherits=abstract_sales_mapper,
polymorphic_identity=6, properties={
        '_valid_until':
transactions.c.valid_until
    })

The error occurs when performing a query on Transaction ex:
Transaction.query.get(111)
where row id 111 is a Quote type. If a query uses the specific class
type ex: Quote.query.get(111)
it completes successfully.

I don't know if this is an SA bug or an error in my mappers. Any help
is appreciated.

-brad

Full Traceback
===========
In [53]: m.Transaction.query.get(112)
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (141, 0))

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call
last)

C:\Documents and Settings\bwells\workspace\ERP GIT TEST\erp\<ipython
console> in <module>()

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\query.pyc in get(self, ident, **kw
args)
    267
    268         key = self.mapper.identity_key_from_primary_key(ident)
--> 269         return self._get(key, ident, **kwargs)
    270
    271     def load(self, ident, raiseerr=True, **kwargs):

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\query.pyc in _get(self, key, ident
, refresh_instance, lockmode, only_load_props)
   1066         try:
   1067             # call using all() to avoid LIMIT compilation
complexity
-> 1068             return q.all()[0]
   1069         except IndexError:
   1070             return None

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\query.pyc in all(self)
    876
    877         """
--> 878         return list(self)
    879
    880

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\query.pyc in iterate_instances(sel
f, cursor, *mappers_or_columns, **kwargs)
   1001                 rows = []
   1002                 for row in fetch:
-> 1003                     process[0](context, row, rows)
   1004             elif single_entity:
   1005                 rows = [process[0](context, row) for row in
fetch]

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\query.pyc in main(context, row, re
sult)
   1579                     row = context.row_adapter(row)
   1580                 self.mapper._instance(context, row, result,
-> 1581                     extension=context.extension,
only_load_props=context.only_load_props, refresh_instance=conte
xt.refresh_instance
   1582                 )
   1583         elif context.row_adapter:

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\mapper.pyc in _instance(self, cont
ext, row, result, polymorphic_from, extension, only_load_props,
refresh_instance)
   1366                     raise exceptions.AssertionError("No such
polymorphic_identity %r is defined" % discriminator
)
   1367                 if mapper is not self:
-> 1368                     return mapper._instance(context, row,
result=result, polymorphic_from=self)
   1369
   1370         # determine identity key

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\mapper.pyc in _instance(self, cont
ext, row, result, polymorphic_from, extension, only_load_props,
refresh_instance)
   1457
   1458                 if 'populate_instance' not in
extension.methods or extension.populate_instance(self, context, ro
w, instance, only_load_props=attrs, instancekey=identitykey,
isnew=isnew) is EXT_CONTINUE:
-> 1459                     self.populate_instance(context, instance,
row, only_load_props=attrs, instancekey=identityke
y, isnew=isnew)
   1460
   1461         if result is not None and ('append_result' not in
extension.methods or extension.append_result(self, con
text, row, instance, result, instancekey=identitykey, isnew=isnew) is
EXT_CONTINUE):

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\mapper.pyc in populate_instance(se
lf, selectcontext, instance, row, ispostselect, isnew,
only_load_props, **flags)
   1507
   1508         for (key, populator) in populators:
-> 1509             selectcontext.exec_with_path(self, key, populator,
instance, row, ispostselect=ispostselect, isnew=i
snew, **flags)
   1510
   1511         if self.non_primary:

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\query.pyc in exec_with_path(self,
mapper, propkey, fn, *args, **kwargs)
   1701         self.path += (mapper.base_mapper, propkey)
   1702         try:
-> 1703             return fn(*args, **kwargs)
   1704         finally:
   1705             self.path = oldpath

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\strategies.pyc in new_execute(inst
ance, row, isnew, **flags)
     84             def new_execute(instance, row, isnew, **flags):
     85                 if isnew:
---> 86
instance._state.expire_attributes([self.key])
     87             if self._should_log_debug:
     88                 self.logger.debug("Deferring load for %s %s" %
(mapper, self.key))

C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg
\sqlalchemy\orm\attributes.pyc in expire_attribute
s(self, attribute_names)
    870                 self.committed_state.pop(key, None)
    871                 self.expired_attributes.add(key)
--> 872                 if getattr(self.class_,
key).impl.accepts_scalar_loader:
    873                     self.callables[key] = self
    874

AttributeError: 'property' object has no attribute 'impl'
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Ross Vandegrift | 18 Aug 16:06

sqlalchemy 0.4 and multiple database binds


Hello everyone,

According to the Pylons wiki docs on multiple engines with SQLALchemy
0.4, I should be able to do:

def init_model(default_engine, alternate_engine):
    binds = { 'tableA': default_engine,
              'tableB': alternate_engine }
    meta.session = orm.scoped_session(orm.sessionmaker(binds=binds))

This doesn't work for me on Pylons 0.9.6.2 and SQLAlchemy 0.4.7.  Is
the example out of date?

I've reviewed the code in sqlalchemy.orm.sessionmaker and I don't see
anything that does something with a kwarg "binds", only "bind" - which
leads me to believe that the documentation gives the incorrect
approach.

--

-- 
Ross Vandegrift
ross <at> kallisti.us

"The good Christian should beware of mathematicians, and all those who
make empty prophecies. The danger already exists that the mathematicians
have made a covenant with the devil to darken the spirit and to confine
man in the bonds of Hell."
	--St. Augustine, De Genesi ad Litteram, Book II, xviii, 37

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Mike Bernson | 17 Aug 20:37

question on on_reconstitue mapper extension


I have the following setup

  CREATE TABLE `med_room_layout` (
   `id` bigint(20) NOT NULL auto_increment,
   `hallid` bigint(20) NOT NULL,
   `room` varchar(16) NOT NULL,
   `nursing_group_id` bigint(20) NOT NULL,
   `bed_count` int(1) default NULL,
   PRIMARY KEY  (`id`),
   UNIQUE KEY `room_2` (`room`,`hallid`),
   KEY `hallid` (`hallid`),
   KEY `nursing_group_id` (`nursing_group_id`),
   KEY `room` (`room`),
   CONSTRAINT `med_room_layout_ibfk_1` FOREIGN KEY (`hallid`) REFERENCES `med_hall_layout` (`id`) ON
UPDATE CASCADE,
   CONSTRAINT `med_room_layout_ibfk_2` FOREIGN KEY (`nursing_group_id`) REFERENCES
`med_nursing_group` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=77 DEFAULT CHARSET=latin1

  CREATE TABLE `med_bed_layout` (
   `id` bigint(20) NOT NULL auto_increment,
   `roomid` bigint(20) NOT NULL,
   `bed` varchar(16) NOT NULL,
   PRIMARY KEY  (`id`),
   UNIQUE KEY `bed` (`bed`,`roomid`),
   KEY `roomid` (`roomid`),
   CONSTRAINT `med_bed_layout_ibfk_1` FOREIGN KEY (`roomid`) REFERENCES `med_room_layout` (`id`) ON
UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=132 DEFAULT CHARSET=latin1

I have set a relation on room:
beds=relations(bed_map, lazy=False, uselist=True)

I a using a mapping extension that has a on_reconsitute.

At the time on_reconsitute is called there is only 1 bed row room.beds. There
are 2 rows in the database. I turned on echoing to get the query that was run
for loading rooms. It show both rows.

The second row is add sometime after the call in on_reconsitute. Is the way thing
are meant to happen ?

Here is the query and the output show bed a and bed b
  SELECT med_room_layout.id AS med_room_layout_id, med_room_layout.hallid AS
med_room_layout_hallid, med_room_layout.room AS med_room_layout_room,
med_room_layout.nursing_group_id AS med_room_layout_nursing_group_id,
med_room_layout.bed_count AS 
med_room_layout_bed_count, med_bed_layout_1.id AS med_bed_layout_1_id, med_bed_layout_1.roomid
AS med_bed_layout_1_roomid, med_bed_layout_1.bed AS med_bed_layout_1_bed,
med_nursing_group_1.id AS med_nursing_group_1_id, med_nursing_group_1.group_name AS 
med_nursing_group_1_group_name, med_nursing_group_1.group_description AS
med_nursing_group_1_group_description, med_hall_layout_1.id AS med_hall_layout_1_id,
med_hall_layout_1.hall AS med_hall_layout_1_hall, med_hall_layout_1.med_delay AS 
med_hall_layout_1_med_delay  FROM med_room_layout LEFT OUTER JOIN med_bed_layout AS
med_bed_layout_1 ON med_room_layout.id = med_bed_layout_1.roomid LEFT OUTER JOIN
med_nursing_group AS med_nursing_group_1 ON med_nursing_group_1.id = 
med_room_layout.nursing_group_id LEFT OUTER JOIN med_hall_layout AS med_hall_layout_1 ON
med_hall_layout_1.id = med_room_layout.hallid  WHERE med_room_layout.hallid=1;
+--------------------+------------------------+----------------------+----------------------------------+---------------------------+---------------------+-------------------------+----------------------+------------------------+--------------------------------+---------------------------------------+----------------------+------------------------+-----------------------------+
| med_room_layout_id | med_room_layout_hallid | med_room_layout_room |
med_room_layout_nursing_group_id | med_room_layout_bed_count | med_bed_layout_1_id |
med_bed_layout_1_roomid | med_bed_layout_1_bed | med_nursing_group_1_id | 
med_nursing_group_1_group_name | med_nursing_group_1_group_description | med_hall_layout_1_id |
med_hall_layout_1_hall | med_hall_layout_1_med_delay |
+--------------------+------------------------+----------------------+----------------------------------+---------------------------+---------------------+-------------------------+----------------------+------------------------+--------------------------------+---------------------------------------+----------------------+------------------------+-----------------------------+
|                 33 |                      1 | 049                  |                                5 |                         2 |                  59 |                      33 | A                    |                      5 | PINK 
       | PINK HALL                             |                    1 | PINK                   |                           2 |
|                 33 |                      1 | 049                  |                                5 |                         2 |                  60 |                      33 | B                    |                      5 | PINK 
       | PINK HALL                             |                    1 | PINK                   |                           2 |
|                 34 |                      1 | 050                  |                                5 |                         2 |                  61 |                      34 | A                    |                      5 | PINK 
       | PINK HALL                             |                    1 | PINK                   |                           2 |
|                 34 |                      1 | 050                  |                                5 |                         2 |                  62 |                      34 | B                    |                      5 | PINK 
       | PINK HALL                             |                    1 | PINK                   |                           2 |
|                 35 |                      1 | 051                  |                                5 |                         2 |                  63 |                      35 | A                    |                      5 | PINK 
       | PINK HALL                             |                    1 | PINK                   |                           2 |
|                 35 |                      1 | 051                  |                                5 |                         2 |                 132 |                      35 | B                    |                      5 | PINK 
       | PINK HALL                             |                    1 | PINK                   |                           2 |
|                 36 |                      1 | 052                  |                                5 |                         2 |                  64 |                      36 | A                    |                      5 | PINK 
       | PINK HALL                             |                    1 | PINK                   |                           2 |
|                 36 |                      1 | 052                  |                                5 |                         2 |                  65 |                      36 | B                    |                      5 | PINK 
       | PINK HALL                             |                    1 | PINK                   |                           2 |
|                 37 |                      1 | 053                  |                                5 |                         2 |                  66 |                      37 | A                    |                      5 | PINK 
       | PINK HALL                             |                    1 | PINK                   |                           2 |
|                 37 |                      1 | 053                  |                                5 |                         2 |                  67 |                      37 | B                    |                      5 | PINK 
       | PINK HALL                             |                    1 | PINK                   |                           2 |
|                 38 |                      1 | 054                  |                                5 |                         2 |                  68 |                      38 | A                    |                      5 | PINK 
       | PINK HALL                             |                    1 | PINK                   |                           2 |
|                 38 |                      1 | 054                  |                                5 |                         2 |                  69 |                      38 | B                    |                      5 | PINK 
       | PINK HALL                             |                    1 | PINK                   |                           2 |
|                 39 |                      1 | 055                  |                                5 |                         2 |                  70 |                      39 | A                    |                      5 | PINK 
       | PINK HALL                             |                    1 | PINK                   |                           2 |
|                 39 |                      1 | 055                  |                                5 |                         2 |                  71 |                      39 | B                    |                      5 | PINK 
       | PINK HALL                             |                    1 | PINK                   |                           2 |
|                 40 |                      1 | 056                  |                                5 |                         2 |                  72 |                      40 | A                    |                      5 | PINK 
       | PINK HALL                             |                    1 | PINK                   |                           2 |
|                 40 |                      1 | 056                  |                                5 |                         2 |                  73 |                      40 | B                    |                      5 | PINK 
       | PINK HALL                             |                    1 | PINK                   |                           2 |
+--------------------+------------------------+----------------------+----------------------------------+---------------------------+---------------------+-------------------------+----------------------+------------------------+--------------------------------+---------------------------------------+----------------------+------------------------+-----------------------------+

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Victor Lin | 17 Aug 14:48

SQLAlchemy getting slow when do a lots of things in transaction


Hi,

I am using SQLAlchemy to write a application.
I add a losts of rows into database and commit.

Code like this:

for item in itemList:
     # do some query
     session.query(...)
     # add a row
     newItem = newItem(...)
session.commit()

At first few rows, it gos fast.
But after that, I found the loop getting slow when there is more and
more data in one transaction.
If I put commit inside loop, it runs very fast.

for item in itemList:
     # do some query
     session.query(...)
     # add a row
     newItem = newItem(...)
     session.commit()

What makes my program getting slow? And how to solve that problem(all
stuff in transaction).
Thanks.

Victor Lin.
--~--~---------~--~----~------------~-------~--~----~
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