I'm new user of SQLObject and now i have a problem.

I want to use "Nortwind"  of MS SQL 2000.

I want to use Orders, OrderDetails, Product

Photo of RelationShip

http://images.temppic.com/01-05-2007/images_vertis/1178032644_0.06632000.png

I have problem with OrderDetails.

I don't know how to create on SQLObject.

I use Turbogears.

My Model.py is


"
from turbogears.database import PackageHub
from sqlobject import *

hub = PackageHub("ordercontrol")
__connection__ = hub

# class YourDataClass(SQLObject):
#     pass

class Orders(SQLObject):

   class sqlmeta:
       idName = 'OrderID'
       style= MixedCaseStyle(longID=True)
   CustomerID = UnicodeCol(length=5)
   EmployeeID = IntCol()
   OrderDate = DateTimeCol()
   RequiredDate = DateTimeCol()
   ShippedDate = DateTimeCol()
   ShipVia = IntCol()
   Freight = CurrencyCol()
   ShipName = UnicodeCol(length=40)
   ShipAddress = UnicodeCol(length=60)
   ShipCity = UnicodeCol(length=15)
   ShipRegion = UnicodeCol(length=15)
   ShipPostalCode = UnicodeCol(length=10)
   ShipCountry = UnicodeCol(length=15)

class OrderDetails(SQLObject):
   class sqlmeta:
       table = 'OrderDetails'
       idName = 'OrderID'
       style = MixedCaseStyle(longID=True)
   Order = ForeignKey('Orders',unique=False)
   Product = ForeignKey('Products',unique=False)
   UnitPrice = CurrencyCol(notNone= True)
   Quantity = IntCol(length=256,notNone=True)
   Discount = FloatCol(notNone=True)

class Products(SQLObject):
   class sqlmeta:
       idName='ProductID'
       style = MixedCaseStyle(longID=True)
   ProductName = UnicodeCol(length=40,notNone=True)
   SupplierID = IntCol()
   CategoryID = IntCol()
   QuantityPerUnit = UnicodeCol(length=20)
   UnitPrice = CurrencyCol()
   UnitsInStock = IntCol()
   UnitsOnOrder = IntCol()
   ReorderLevel = IntCol()
   Discontinued = BoolCol(notNone=True)
"

But it have problem , it show only 1 ProductID / 1 OrderID. it incorrect!
if true it show "many" ProductID / 1 OrderID

How did i will do ?

Thank You Very Much.

[My english is pool]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to