Hmm, that's not the solution I was hoping for, but that will work. Thanks!
Kenny On Jun 9, 12:07 pm, Wooble <[email protected]> wrote: > GQL only has a SELECT statement, so using it to add data to the > datastore is a nonstarter. > > You wanthttp://code.google.com/appengine/docs/python/tools/uploadingdata.html > most likely. > > On Jun 9, 1:48 pm, KennyCarlile <[email protected]> wrote: > > > > > Pranav, > > > Thanks for your reply, but templating is not what I'm looking for. I > > just used the dropdown list as an example. > > > I want to load data into the datastore before anyone uses that system > > and I don't want to create a form to enter it. That is, think of any > > data that you might have in a system that would need to be there prior > > to the system going live. How does that data get there? Sure, some of > > it might be able to be entered through forms, but surely some of it > > just exists to be pulled from the DB. > > > Normally, to add this data to a non-GAE system, say, with a MySQL > > backend, I'd just create a script to run against the empty DB. It > > would just have a series of INSERT statements to preload data: > > > INSERT INTO PostCategories ('name', 'displayOrder'....) VALUES > > 'Articles', 1... > > INSERT INTO PostCategories ('name', 'displayOrder'....) VALUES > > 'Tutorials', 2... > > INSERT INTO PostCategories ('name', 'displayOrder'....) VALUES 'News', > > 3... > > > ...and so on. > > > I want those preloaded in the DB because, when I go to create > > articles, those types need to exist. If the categories were likely to > > change a lot, I might create a form to create and edit categories, but > > for small apps with relatively static categories, I may not > > (initially) create those forms. > > > Now, I recognize that this is a bad example, because someone could > > just say, "If it's not going to change, just hardcode the dropdown > > list in the template". While I could do that, I don't want to do that. > > Just because I'm not going to code a form to create/edit a table in > > the DB doesn't mean that I don't want the proper data representation. > > That's why I recognize this might be a bad example, but I'm not > > working on a current project that I can pull a specific example from. > > > Anyway, my question is this: how would I get that data into the GAE > > datastore? What is the standard way people go about putting data in > > the datastore that isn't inserted by submitting it through a form? > > Should I just create a script that has a bunch of Python object > > instantiations with the data I want and then push those to the > > datastore and then call that script by loading a page? That's how I've > > done it in the past and it just seems like there should be a better > > way. It seems like I should be able to create a YAML file or a GQL > > file, drop it in the file system, and then tell GAE to parse that text > > file to load the data, rather than executing static Python code. > > > Thanks. > > > Kenny > > > On Jun 9, 12:20 am, pranny <[email protected]> wrote: > > > > Hey Kenny, > > > > I was a little confused what meant by 'Data Preload script', but i > > > think i am clear now :-) > > > > Basically, you want to create dynamic stuff (forms, in our case) with > > > as little typing and as high flexibility as possible. > > > > 1. use > > > templateshttp://code.google.com/appengine/docs/python/gettingstarted/templates... > > > > 2. use django form (validation) > > > frameworkhttp://code.google.com/appengine/articles/djangoforms.html > > > > I hope these two urls are good enough to solve your problem. > > > > Revert back, for more clarifications :) > > > > -- > > > Pranav Prakash > > > > "This life is more than ordinary" > > > >http://codecontrol.blogspot.com > > > > On Jun 9, 3:55 am, KennyCarlile <[email protected]> wrote: > > > > > I'm pretty new to GAE, but I've searched around and have been unable > > > > to find a solution to this problem, although it's quite possible that > > > > I didn't ask the right question when searching. :o) > > > > > When creating an application in PHP/MySQL, I would often write SQL > > > > scripts to create the DB and permissions, create tables/stored procs/ > > > > views, and then a script to prepopulate data, such as config values, > > > > types, dropdown lists, etc. It's that last script I'm curious about. > > > > > So say, for example, that I have a dropdown with usertype (for > > > > creating new users) but I don't want that value hardcoded in the > > > > template. I have values for "admin", "editor", and "contributor". (For > > > > the sake of the argument, please disregard that this might be a bad > > > > example.) Normally, I'd have a table called UserTypes and I'd create a > > > > script to insert 3 values into that table. > > > > > Here's the question: how would I do that in GAE? Remember, this > > > > presumes that I don't want the values hardcoded in Python (in > > > > handlers), HTML, and I don't want to have to create a form to enter > > > > all these by hand. > > > > > The only solution that I've come up with is to have an admin-section > > > > page that preloads the database by first wiping the data from the > > > > types that I want to load and then by manually creating 3 Python > > > > objects and writing those to the DB. So in this case, I'm basically > > > > using Python for my data preload script. This isn't how I want to do > > > > this. I'd really like to just be able to have a script file with SQL > > > > (err...GQL) to preload data into the datastore. Any thoughts on how I > > > > could do this? > > > > > Thanks for any help that anyone can offer. > > > > > Kenny --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---
