Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 6th, 2012  |  syntax: None  |  size: 1.00 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. designing a database in google app engine
  2. create table User
  3. (
  4.     id int primary key identity(1,1),
  5.     login nvarchar(50) unique not null,
  6.     password nvarchar(50) not null,
  7.     email nvarchar(50) unique not null,
  8. )
  9.  
  10. create table Article
  11. (
  12.     userId int references User(id) not null,
  13.     topic nvarchar(50) not null,
  14.     content nvarchar(max) not null
  15. )
  16.        
  17. class Article(db.Model):
  18.      topic = db.StringProperty(multiline=False)
  19.      content = db.StringProperty(multiline=True)
  20.  
  21. class User(db.Model):
  22.      login = db.StringProperty()
  23.      email = db.EmailProperty()
  24.      password = db.StringProperty(multiline=False)
  25.      articles = db.ListProperty(int) #here I want to do db.ListProperty(Article), but I can't. So I want to keep here id of article.
  26.        
  27. select id from User where login = 'sada' and password = 'sd'
  28.        
  29. query = db.Query(User, keys_only=True)
  30. query.filter('login =', 'sada')
  31. query.filter('password =', 'sd')
  32. user_key = query.get()
  33.        
  34. db.get(user_key)
  35.        
  36. user_key = Key.from_path(User, id_or_name)