Sam's Lists | 1 May 02:16
Picon
Gravatar

Simple select statement using a foreignkey..

So I am writing my own wiki.  Here are my relevant tables:

class WikiPage(SQLObject):
    name = StringCol(alternateID=True, length=40)
    currentVersion = IntCol(default=None)
    lockedTime = DateTimeCol(default=None)
    lockedPerson = IntCol(default=None)
   
class WikiData(SQLObject):
    wikiPage = ForeignKey('WikiPage')
    version = IntCol(default=None)
    time = DateTimeCol.now()
    author = ForeignKey('User')  
    ipnr = StringCol(default=None) # the ip number of committer
    comment = StringCol(default=None)
    text = StringCol() # the actual text of the page

Now, when I do a simple select like:

x = WikiData.select ( WikiData.q.wiki_page_id == 1 ) [:1]

I get:

AttributeError: WikiData instance has no attribute 'wiki_page_id'

When I try replacing wiki_page_id with wiki_page or wikiPage, it still doesn't work.

But when I use version, it works fine.

How can I make it work? (This is just the first step to a more complicated query.)

Thanks



-------------------------------------------------------------------------
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 <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
rdmurray | 1 May 03:56

how to use sqlobject in operator

Or at least, that's what it looks like I want to do.

The relevant part of my model looks like this:

class MoneyStream(SQLObject):
     users = RelatedJoin('User')
     label = UnicodeCol()

class User(SQLObject):
     moneystreams = RelatedJoin('MoneyStream')

What I want to do is, given a user (current.user) and a
label, find the MoneyStream that with that label that
has that user in its users list.  How do I write the
select?  Or should I just scan through User.moneystreams?

--David

-------------------------------------------------------------------------
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/
Watchara Kangkun | 1 May 17:25
Picon

New User Problem

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 <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Chan Yong Wei | 1 May 17:32
Picon

Re: how to use sqlobject in operator

Wouldn't it simply be

for ms in current.user.moneystreams:
  print ms.label

?

On 5/1/07, rdmurray <at> bitdance.com <rdmurray <at> bitdance.com> wrote:
> Or at least, that's what it looks like I want to do.
>
> The relevant part of my model looks like this:
>
> class MoneyStream(SQLObject):
>      users = RelatedJoin('User')
>      label = UnicodeCol()
>
> class User(SQLObject):
>      moneystreams = RelatedJoin('MoneyStream')
>
>
> What I want to do is, given a user (current.user) and a
> label, find the MoneyStream that with that label that
> has that user in its users list.  How do I write the
> select?  Or should I just scan through User.moneystreams?
>
> --David
>
> -------------------------------------------------------------------------
> 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 <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
>

-------------------------------------------------------------------------
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/
rdmurray | 1 May 17:34

Re: how to use sqlobject in operator

On Tue, 1 May 2007 at 16:32, Chan Yong Wei wrote:
> Wouldn't it simply be
>
> for ms in current.user.moneystreams:
>  print ms.label

Yes, that is what I am doing (looping and using an if test).  And it
will be fine, I think, since the number of streams for any given
user is not likely to get above a dozen or so.

--David

-------------------------------------------------------------------------
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/
sophana | 2 May 11:39

Re: New User Problem

Watchara Kangkun a écrit :
>
> 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.
I think you want to create a "Related join".
You should check that in the main SqlObject documentation.

-------------------------------------------------------------------------
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/
sophana | 2 May 11:42

Re: Simple select statement using a foreignkey..

Sam's Lists a écrit :
>
> Now, when I do a simple select like:
>
> x = WikiData.select ( WikiData.q.wiki_page_id == 1 ) [:1]
I think it is

x = WikiData.select ( WikiData.q.wikiPageID == 1 ) [:1]

or

x = WikiData.select ( WikiData.q.wikiPageID == 1 ) .getOne()

-------------------------------------------------------------------------
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/
Oleg Broytmann | 2 May 14:16
X-Face
Picon
Favicon

Holiday

Hello!

   May 1st is the Labor Day holiday in Russia. I was busy celebrating it ;)
and didn't answer mail. But I saved all messages and will answer them.

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
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/
Oleg Broytmann | 2 May 14:22
X-Face
Picon
Favicon

Re: Problems with LEFTJOINOn and Alias

On Mon, Apr 30, 2007 at 06:54:09PM -0300, Claudio Martinez wrote:
> http://paste.turbogears.org/paste/1248
> function is here http://paste.turbogears.org/paste/1249
> http://paste.turbogears.org/paste/1250
> http://paste.turbogears.org/paste/1251

   Sorry, I am not going to look at all this. Please simplify things down
to a script of a dozen of lines. One or two tables are usually enough to
demonstrate the problem.
   And of course use only SQLObject. I don't use and don't know TurboGears.

> For some reason the alias tables are getting inner and left joined, so I'm
> getting this error:
> 
> OperationalError: ambiguous column name: customer_person.id

   Either you have to rewrite JOINs so that the table mentioned once in the
query or use aliases.

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
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/
Oleg Broytmann | 2 May 15:03
X-Face
Picon
Favicon

Re: Link to wiki mysteriously hard to find...

On Mon, Apr 30, 2007 at 03:57:24PM -0700, Sam's Lists wrote:
> Does anyone have source code access to the trac where they can tweak this?

   Only the Trac admin, and I don't know if (s)he is still subscribed to
the list.

> In the meantime only that and the Gazpacho pages are still missing.

   Thank you for the job!

> So, I think it is an appropriate time for a prominent link to the new wiki
> on the sqlobject page.  :)

   It is at http://sqlobject.org/community.html . Isn't it enough? I think
I can drop "experimental" status.

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
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/

Gmane