Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7892885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:58:47+00:00 2026-06-03T06:58:47+00:00

I am learning developing web app on google app engine, and I encounter a

  • 0

I am learning developing web app on google app engine, and I encounter a trouble.
I have some default users in my app and I write a function createDefaultUsers to create a User table using a list of their information in my python file. I hope to create this User table just once and every time I use my app, the data just there. But you know, the createDefaultUsers function is in my python file, so, very time I use my app, I just create this User table again and again. OGM~How can I fix this problem?

another question:
How can I clear my local datastore? It may help me debug my app, you know, sometime I just want to start again.

————–Update—————-

For example, here is some default users :

defaultUsers = [
('qingWANG','wang123456','wangqing@saad.com','teacher'),
('stevenYANG','123456','yifan@gmail.com','student'),
('jingZHU','zhu123456','zhujing@example.com','student'),
('conghuiHE','he123456','conghui@where.com','student'),
('lianDUAN','duan123456','duanlian@what.com','student'),
('xinHAO','hao123456','haoxin@example.com','student')]

and here is my function which create Users:

def createDefaultUsers():
"""
create default user table
"""
for user in defaultUsers:
    users = Users(name = user[0], password = user[1],
                  email = user[2], role = user[3])
    users.put()

In my first think, I put createDefaultUsers here:

def main():
    createDefaultUsers()
    run_wsgi_app(app)
if __name__ == "__main__":
    main()

It is fine in my local testing. But when I deploy this, It doesn’t work (seems no Users created). where am I wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:58:48+00:00Added an answer on June 3, 2026 at 6:58 am

    You can easily modify the function to check to see if there are any existing users and if there are, don’t create them:

    def createDefaultUsers():
        """
        create default user table
        """
        user_count = Users.all().count(1)
        if user_count == 0:
            for user in defaultUsers:
                new_user = Users(name = user[0], password = user[1],
                      email = user[2], role = user[3])
                new_user.put()
    

    Do note that the count() query operation is expensive because it actually retrieves all of the entities from the datastore in order to count them, so it is to be avoided in common practice, but by specifying a limit of 0, we can make it simple and quick in this case.

    You can empty out your development datastore by passing the command line argument --clear-datastore to the development server. Here are all of dev_appserver.py command line arugments

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an intranet web app and I'm learning how to hook VB into
I'm developing a Grails web application (mainly as a learning exercise). I have previously
I'm kind of new to rails - I'm currently learning by developing a web-app,
Its been quite some time since i have started developing web pages using JSF
I'm developing a Python web app as a learning exercise, and I am looking
I'm developing a Spring web app and am hoping someone can give me some
I'm learning MVVM with the hope of developing an app that uses the phone's
As part of my learning, i am developing a google maps V3 application, to
I'm developing a web app with Spring and Hibernate and I was so obsessed
I learning Python (coming from a dotnet background) and developing an app which interacts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.