希增毛 | 3 Dec 17:29 2007
Picon

Database integrity error (non unique primary key) when adding objects all referring other objects

Hi Storm developers,

Recently, I have been trying your great product, Storm.   Many nice features are found there :-)  But I encounter a weird and messing database integrity error.  To see how, just run the attached test.py.  I am using storm trunk version.

Could you help me?  Thanks a lot in advance.

Best regards,

Xizeng Mao

Attachment (test.py): text/x-python, 1009 bytes
<div><p>Hi Storm developers,<br><br>Recently, I have been trying your great product, Storm.&nbsp;&nbsp; Many nice features are found there :-)&nbsp; But I encounter a weird and messing database integrity error.&nbsp; To see how, just run the attached 
test.py.&nbsp; I am using storm trunk version.<br><br>Could you help me?&nbsp; Thanks a lot in advance.<br><br>Best regards,<br><br>Xizeng Mao<br></p></div>
Gustavo Niemeyer | 3 Dec 17:33 2007
Picon

Re: Database integrity error (non unique primary key) when adding objects all referring other objects

Hello 希增毛,

(...)
> Could you help me?  Thanks a lot in advance.

class B(object):
    (...)
    a_id = Int()
    a = Reference(id, A.id)

You want a_id as the first argument here, rather than id.

-- 
Gustavo Niemeyer
http://niemeyer.net

--

-- 
storm mailing list
storm <at> lists.canonical.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/storm
Christopher Armstrong | 3 Dec 17:36 2007

Re: Database integrity error (non unique primary key) when adding objects all referring other objects

On Dec 3, 2007 11:29 AM, 希增毛 <xizeng.mao <at> gmail.com> wrote:
> Hi Storm developers,
>
> Recently, I have been trying your great product, Storm.   Many nice features
> are found there :-)  But I encounter a weird and messing database integrity
> error.  To see how, just run the attached test.py.  I am using storm trunk
> version.
>
> Could you help me?  Thanks a lot in advance.

Hi Xizeng. Your Reference is incorrect. It should be Reference(a_id,
A.id), not Reference(id, A.id). What you have now makes Storm thinks
that "id" is the foreign key to A.id.

-- 
Christopher Armstrong
International Man of Twistery
http://radix.twistedmatrix.com/
http://twistedmatrix.com/
http://canonical.com/
--

-- 
storm mailing list
storm <at> lists.canonical.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/storm
Ana Júlia | 3 Dec 20:58 2007
Picon

creating table

i learned in the tutorial that i have to create a table at the end of the class. How i should  to do to create all tables in the end of the program?

<div><p>i learned in the tutorial that i have to create a table at the end of the class. How i should&nbsp; to do to create all tables in the end of the program?<br></p></div>
Tim Stebbing | 4 Dec 00:16 2007
Picon

Re: creating table

G'day Ana, if you are writing a proper app you would most likely
create your tables in SQL and import them into postgres/mysql etc.

If you are using sqlite then I've got a little Table() class I've
written to bootstrap some databases/tables for our test-suite, feel
free to use it in your application. Simply change the Table()
instances at the bottom of the file, then import the module and call
setup(), it will do the rest (see attached file) I've left in some of
the test tables as an example.

usage:

Table('databasename','tablename',*fields)

Hope this helps

-tjs

On Dec 4, 2007 6:58 AM, Ana Júlia <anajrfoliveira <at> gmail.com> wrote:
> i learned in the tutorial that i have to create a table at the end of the
> class. How i should  to do to create all tables in the end of the program?
>
> --
> storm mailing list
> storm <at> lists.canonical.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/storm
>
>

-- 
Timothy J Stebbing
Attachment (_testDB.py): text/x-python, 5556 bytes
G'day Ana, if you are writing a proper app you would most likely
create your tables in SQL and import them into postgres/mysql etc.

If you are using sqlite then I've got a little Table() class I've
written to bootstrap some databases/tables for our test-suite, feel
free to use it in your application. Simply change the Table()
instances at the bottom of the file, then import the module and call
setup(), it will do the rest (see attached file) I've left in some of
the test tables as an example.

usage:

Table('databasename','tablename',*fields)

Hope this helps

-tjs

On Dec 4, 2007 6:58 AM, Ana Júlia <anajrfoliveira <at> gmail.com> wrote:
> i learned in the tutorial that i have to create a table at the end of the
> class. How i should  to do to create all tables in the end of the program?
>
> --
> storm mailing list
> storm <at> lists.canonical.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/storm
>
>

--

-- 
Timothy J Stebbing
Morten Siebuhr | 9 Dec 13:09 2007
Picon

Query questions and misc. comments

Hi all,

I've been digging into Storm for a few weeks now, and I seem to have hit
the wall a few places. Any help will be appreciated.

     1. It is in no way obvious from the tutorial or manual-page how one
        does stuff like NOT, LIKE, IN, AND and OR in Storm. I've seen
        hints on this list and the code documentation, but only in small
        doses.
     2. From reading the generated documentation - it seems sub-queries
        are possible, but I can't really figure out how.
     3. How - if at all - does Storm handle VIEWs? I'd really like to
        hide away some of the complex queries, but I'd prefer not to
        give up using Storm-objects.

A small note to the wiki-admins: The links to the mailing list should
apparently be https://lists.ubuntu.com/mailmain/listinfo/storm (as the
link to https://lists.canonical.com gives an invalid SSL-cert error).

--

-- 
Morten Siebuhr

Stephan Diehl | 11 Dec 17:05 2007
Picon
Picon

question about ReferenceSet

Hi all,

I'm new to storm and really like it so far. Until now I've used my own 
homegrown database wrapper (so I can't compare to SQLAlchemy or SQLObject). 
I've a question about ReferenceSet. The name implies some relation to, well, 
sets. Is it planned that the set interface will be supported sometimes in the 
future?

For example, if I have some classes 'User' and 'Group', I'd like to be able to 
do something like this:
accessGroups = set([grp1, grp2, grp3])
if usr.groups & accessGroups:
	doSomething

Thanks for your patience

Stephan

Håvard Gulldahl | 11 Dec 21:46 2007
Picon

Re: Query questions and misc. comments

[Re-sending the reply that I by accident sent to Morten privately]

Hi Morten,

I feel your frustration. I've only just started using storm myself.
While the tutorial is great for learning the tutorial, all the other
stuff is a bit more veiled. In my experience, the best way to explore
storm is

1) study the source files  (obviously ;)
2) turn on debugging, since you'll see the sql query that storm
expands from your code:

import storm.database
storm.database.DEBUG = True

On 12/9/07, Morten Siebuhr <msiebuhr@...> wrote:
>      1. It is in no way obvious from the tutorial or manual-page how one
>         does stuff like NOT, LIKE, IN, AND and OR in Storm. I've seen

It's not obvious at first. After a while it's just easy as pie. Check
it (code semi-tested):

LIKE:
store.find(klass, klass.col.like('%skabelone'))

NOT:
from storm.expr import Not
store.find(klass, Not(klass.col < 10))

IN:
from storm.expr import In
store.find(klass, In(klass.id, [1,2,3,10,11,12]))

AND/OR:
from storm.expr import And, Or
expr1 = And(klass.col == 2, klass.disabled == False)
store.find(klass, Or(klass.sticky, expr1))

So, since this is all serializable, you can easily build up a python
list of expressions, and then, And() or Or() it together, depending on
your application:

expressions = []
#... loop through input and build atomic expressions, e.g. ...
#  expressions += [ stormer.lastname.like('%buhr') ]
#  expressions += [ stormer.gender == 'Male' ]
# and then:
store.find(stormer, And(*expressions))

>      2. From reading the generated documentation - it seems sub-queries
>         are possible, but I can't really figure out how.

SELECT:
from storm.expr import Select, In
expr1 = Select(klass2, klass2.enabled == True)
store.find(klass, In(klass.foreignId, expr1))

>      3. How - if at all - does Storm handle VIEWs? I'd really like to
>         hide away some of the complex queries, but I'd prefer not to
>         give up using Storm-objects.

I don't know anything about this.

Hope this helps,

Håvard

--
Håvard Gulldahl <havard@...>

--

-- 
storm mailing list
storm@...
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/storm

Gustavo Niemeyer | 11 Dec 23:19 2007
Picon

Re: Query questions and misc. comments


Hey guys,

> 1) study the source files  (obviously ;)
> 2) turn on debugging, since you'll see the sql query that storm
> expands from your code:
> 
> import storm.database
> storm.database.DEBUG = True

And probably

3) Bother the insensible people who wrote it to write more documentation.
4) Contribute some documentation to the manual.

> IN:
> from storm.expr import In
> store.find(klass, In(klass.id, [1,2,3,10,11,12]))

That's more easily written as

  Class.id.is_in([1,2,3])

> AND/OR:
> from storm.expr import And, Or
> expr1 = And(klass.col == 2, klass.disabled == False)
> store.find(klass, Or(klass.sticky, expr1))

This also works as

  (Class.col == 2) & (Class.disabled == False)

It may bite sometimes because the precedence rules are inverted
(taking off the parenthesis will produce unexpected results), so
your suggestion may be preferred.

>>      3. How - if at all - does Storm handle VIEWs? I'd really like to
>>         hide away some of the complex queries, but I'd prefer not to
>>         give up using Storm-objects.
> 
> I don't know anything about this.

I believe you can pretty much put a view where a table name is
expected and have it working.  The normal rules for updating views
apply.

> Hope this helps,

Thanks a lot for these explanations, Håvard.

-- 
Gustavo Niemeyer
http://niemeyer.net

--

-- 
storm mailing list
storm@...
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/storm

Gustavo Niemeyer | 11 Dec 23:46 2007
Picon

Re: question about ReferenceSet

Hello Stephan,

> I'm new to storm and really like it so far. Until now I've used my own 
> homegrown database wrapper (so I can't compare to SQLAlchemy or SQLObject). 

I'm glad that you enjoy it.

> I've a question about ReferenceSet. The name implies some relation to, well, 
> sets. Is it planned that the set interface will be supported sometimes in the 
> future?

It may be, but notice that the "set" naming isn't about being able to do
Python-style set operations in this case, but rather about the fact that
this type offers access to "a set of referenced objects".

> For example, if I have some classes 'User' and 'Group', I'd like to be able to 
> do something like this:
> accessGroups = set([grp1, grp2, grp3])
> if usr.groups & accessGroups:
> 	doSomething

This does look like an interesting feature, and at first sight I can't
think of any incoveniences about it.  It's been added it to the TODO
file for future consideration.

Thanks for the suggestion.

--

-- 
Gustavo Niemeyer
http://niemeyer.net


Gmane