OK, so it's a verified problem in the trunk with cross-schema queries MSSQL.
File a bug with a reproducable test case (in general, reflected tables don't
work well for test cases) and we'll take a look at it.
On 2/15/07, metaperl <[EMAIL PROTECTED]> wrote:
>
>
> It's that MS-SQL weenie metaperl back at ya with another problem with
> the latest svn SA:
>
> The multi-part identifier "KEContracts.refnum" could not be bound.
>
> Bottom line is that there WHERE part of the SQL looks like this:
> WHERE [KEContracts].refnum = %(KEContracts_refnum)s
>
> and it is a fact that we need to either remove the [KEContracts]. from
> in front of the refnum declaration, or add .[dataTables]. between
> [KEContracts] and [refnum] to fix.
>
>
>
>
> Here is my source code:
>
> #!/usr/bin/env python
>
> from pyparsing import *
> import pprint, sys
> import data.config.db
> from sqlalchemy import *
>
> sa = data.config.db.sqlalchemy(schema="DataTables", echo=False)
>
>
> ke_contracts = Table('KEContracts', sa.metadata, autoload=True,
> schema="DataTables")
>
> f = open('UK_Agg.txt')
>
>
>
> for i, line in enumerate(f.read().split('|||')):
> print "line #", i
> rec = delimitedList(QuotedString('"',escQuote='""',
> multiline=True)).parseString(line)
>
> refnum = rec[0]
> print "\trefnum", refnum
>
> result = ke_contracts.select(ke_contracts.c.refnum ==
> refnum).execute()
>
> dat = dict(
> ParentRefnum = rec[1], # ParentRefNum - int
> Licensee = rec[2], # Licensee
> Licensor = rec[3], # Licensor
> ContractDate = rec[4], # ContractDate - datetime
> #ContractTerms = rec[5], # ContractTerms
> ContractCategory = rec[30], # ContractCategory
> PartIndex = rec[6], # PartIndex - int
> #RRates = 0, # RRates - not in datafile
> GeoRestrict = rec[8], # GeoRestrict
> Industry = rec[30], # Industry
> Exclusive = rec[10], # Exclusive
> UserID = rec[20], # UserID - int
> Status = rec[9], # Status - smallint
> CreateDate = rec[11], # CreateDate - datetime
> RecordDate = rec[13], # RecordDate - datetime
> AgreementType = rec[12], # AgreementType
> )
>
> if result.fetchone() is None:
> print "\t\tINSERT"
> #pprint.pprint(dat)
> dat[refnum] = refnum
> ke_contracts.insert().execute(dat)
> else:
> print "\t\tUPDATE"
> ke_contracts.update(ke_contracts.c.refnum==refnum).execute(**dat)
> sys.exit()
>
>
> class sqlalchemy:
>
> def __init__(self, ip="4.19.18.7" db="DATA", schema="DataTables",
> echo=True):
> conn_url = "mssql://perl2:[EMAIL PROTECTED]:1433/%s" % (ip, db)
> print "conn_url", conn_url
> self.engine = create_engine(conn_url)
>
> self.engine.dialect.set_default_schema_name(schema)
>
> self.engine.echo=echo
> self.metadata = BoundMetaData(self.engine)
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---