Hi Newbie here,
If, using the declarative style of classes, I want to create my tables
separately from actually populating them. I thought I would use
something similar to the following:

###########
from sqlalchemy import *
import time
from datetime import *
from sqlalchemy.ext.declarative import declarative_base

class CST_LEVEL(Base):
    __tablename__ = 'CST_LEVEL'

    REFNO = Column(String(length=10), primary_key=True)
    CODE = Column(String(length=10))
    DESCRIPT = Column(String(length=60))
    def __init__(self, \
        REFNO="", \
        CODE="", \
        DESCRIPT=""):
            self.REFNO = REFNO
            self.CODE = CODE
            self.DESCRIPT = DESCRIPT

engine = create_engine('sqlite:///tutorial.db', echo=False)
metadata = MetaData()
Base = declarative_base()
metadata.create_all(engine)
###########

But this doesn't work I guess because the class never gets
instantiated. If I instantiate the class with x = CST_LEVEL() then I
would create a blank record as a by-product. How do you create the
tables, without records, using the declarative syntax?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@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
-~----------~----~----~----~------~----~------~--~---

Reply via email to