
Untitled
By: a guest on
May 6th, 2012 | syntax:
None | size: 1.00 KB | hits: 15 | expires: Never
designing a database in google app engine
create table User
(
id int primary key identity(1,1),
login nvarchar(50) unique not null,
password nvarchar(50) not null,
email nvarchar(50) unique not null,
)
create table Article
(
userId int references User(id) not null,
topic nvarchar(50) not null,
content nvarchar(max) not null
)
class Article(db.Model):
topic = db.StringProperty(multiline=False)
content = db.StringProperty(multiline=True)
class User(db.Model):
login = db.StringProperty()
email = db.EmailProperty()
password = db.StringProperty(multiline=False)
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.
select id from User where login = 'sada' and password = 'sd'
query = db.Query(User, keys_only=True)
query.filter('login =', 'sada')
query.filter('password =', 'sd')
user_key = query.get()
db.get(user_key)
user_key = Key.from_path(User, id_or_name)