Hi all, i am writing a python script which parse an xml file (python lxml) and import it into a sqlite db, and it works. The xml file size is about 30Mb and the import operation takes about 15 minutes (do you think is too much? is there something i can do to speed up the process?)
This is a piece of the import function: ... for definition in definitions.getchildren(): #iterate for every xml children node defInst = SQLTableBuilder_Definition.DefinitionClass(definition) #read and write on db some attribute of the node ... if subbaElem1.tag == mainNS + "platform": #another loop iterate for every sub-node of the definition node platf = SQLTableBuilder_Platform.PlatformClass() platf.setPlatform(str(subbaElem1)) platf.platformId_fk = defInst.defId session.add(platf) session.commit() ... session.add(defInst) session.commit() where DefinitionClass contains the attributes declaration (primary_key, column(string), etc.) and a Foreign Key. There is a relation between the definition table and the platform table (one or more platforms - Operating System - can be associated to a single definition) so, in the platform table, i've added the following: platformId_fk = Column('definitionId_fk', Integer, ForeignKey('definitions.defId')) All my ORM-Classes are declared within n different classes within n different python modules so, i've included the needed imports everytime i needed it. And i suppose this is a problem, at least for me, sometime, because when i try to add: PlatformRel = relation(SQLTableBuilder_Definition.DefinitionClass, backref="platform") within my platformClass, i got: 'list' object has no attribute '_sa_instance_state' :/ So, i've tried to "manually" set the foreign key, as you can see above. In the documentation (http://www.sqlalchemy.org/docs/ormtutorial.html) i read: " SQLAlchemy is automatically aware of many-to-one/one-to-many based on foreign keys." Does this mean that what i've done is correct or i'm a little confused? If i "manually" set a foreign key value, does sqlalchemy understand that a relation between two tables exists? Thanks for your attention. --- Masetto -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.