Is there a maximum size to a Python program?
darwin at nowhere.com
Mon Apr 27 06:34:45 CEST 2009
Thanks for the reply,
> Sounds like a needlessly complicated way of doing things. Surely
> replicating data from a database is a solved problem?
The data is coming from a legacy system and going into SQLalchemy to give
database independence. We will probably update the legacy apps in the future
but it is a massive job for little benefit.
> I don't understand what you mean by "with no current data". Do you mean
> that you generate 5MG of source code when the original postcode table is
> empty? Or 5MB of source code when the *replicated* table is empty? Or
> something else?
5MB of source code when the replicated table is empty
> Perhaps you could explain what the 5MB of code is supposed to do it, and
> how you generate the code, and show a *small* number of sample lines.
Here is a generated file that works. Other files are essentially the same
but with more entries. This one only adds if the record does not exist, the
next stage was to update an existing record with changes.
# -*- coding: utf-8 -*-
from datetime import *
from sqlalchemy import *
from sqlalchemy.orm import *
engine = create_engine('sqlite:///tutorial.db', echo=False)
Session = sessionmaker(bind=engine)
session = Session()
entry = schema.BILLS()
exists = session.query(schema.BILLS).filter(schema.BILLS.REFNO==u"1")
if exists.count == 0:
entry.REFNO = u"1"
entry.THRDPTY = u"""C5"""
entry.AMOUNT = 0
entry.TIMESTAMP = 0
entry.ALLOCATED = 0
More information about the Python-list