If you don't want to pollute the current namespace, then make an indirect
reference.

1) Make a module of your own, say db.py

2) In db.py:
         ...
      from sqlalchemy import *
      from sqlalchemy.orm import *
         ...
      table1 = Table('footable', ...)
         ...
      # other table defs, mappers, classes, etc.

3) In your non-polluted code:
         ...
      import db    # your indirect reference
         ...
         ...

      qry = db.select([db.table1.c.col], db.table1.c.col2 == 'foo')

So now you have most of the convenience of all of the SqlAlchemy names all
loaded, but your namespace only contains the 'db' indirect reference. You
still need to worry about the 'db' namespace being polluted, but at least
it's only in that one module.



On 10/29/07, McA <[EMAIL PROTECTED]> wrote:
>
>
> Hi all,
>
> I'm intersted in using sqlalchemy and started to read the manuals.
> I didn't find a hint for my question, so I'm asking here. I hope it's
> not too annoying.
>
> Most code examples in the documentation use something like this
> >>>from sqlalchemy.XXXX import YYYY
>
> My question is: Is this the good/proper way to import the sqlalchemy
> stuff.
> I'm concerned about polluting the current namespace. I could assume
> that
> class names like 'Table' are too common to reserve them for the
> sqlalchemy
> classes.
>
> What would you recommend? How are the gurus out there using
> sqlalchemy?
>
> Thanks in advance.
>
> Best regards
> Andreas Mock
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to