On Thursday, November 3, 2005, at 04:42 PM, Adrian Holovaty wrote:


On 11/3/05, David Pratt <[EMAIL PROTECTED]> wrote:
1. Is it possible  to execute the sqlreset or sqlclear statement
through django-admin (opposite of django-admin install) I haven't found
a django-admin drop or an django-admin reset at this point and don't
see anything in the management.py to indicate this is possible. Should
I write this code?

No, there's currently not an option to do that. Sure, feel free to
write the code and submit a patch -- that'd be great.

Ok, sure. These would be nice to have and they are almost there in the code so I don't think it would be too bad.


The commands should probably be the same as the "sql*" commands, just
without the leading "sql". Come to think of it, there's a discrepancy
between the naming convention of "sqlall" and "install" -- one of
those, probably "sqlall", should probably be renamed.

Do you like sql naming - it might be more intuitive to do something like this. I think most people working with sql understand create / drop for sure. Naming of app and project admin could also be createapp and createproject for continuity. Anyway, let me know what you think so I can get started.

django-admin sqlinit mymodel           * new method
django-admin init mymodel                 current - no name change

django-admin sqlcreate mymodel (instead of django-admin sql mymodel) django-admin create mymodel (insead of django-admin install mymodel)

django-admin sqlcreateall mymodel (instead of django-admin sqlall mymodel)
django-admin createall mymodel       * new method

django-admin sqldrop mymodel (instead of django-admin sqlclear mymodel)
django-admin drop mymodel              * new method

django-admin sqldropall mymodel     * new method
django-admin dropall mymodel          * new method

django-admin sqlreset mymodel         current - no name change
django-admin reset mymodel              * new method

django-admin sqlresetall mymodel     *new method
django-admin resetall mymodel          *new method

django-admin sqlindexes mymodel      current - no name change
django-admin indexes mymodel            *new method

django-admin sqlindexesall mymodel      current - no name change
django-admin indexesall mymodel            *new method


2. Is there a way to use a raw SQL statement within the api with a
connection obtained through settings? Let's say I have some large ugly
query with multiple related tables and I want to handle it within the
api but in a raw form.

Yes! Django exposes the "db" object within models, for precisely this
purpose. See the get_articles_from_same_day_2() method in this example
model:

http://www.djangoproject.com/documentation/models/custom_methods/\

Thanks for pointing this out. While I am working with sqlite for desktop situation, I work with postgres for web and still want to write functions or triggers for apps so this helps with this too.

One other thing, is there a debug mode to see interaction with db adapter. I should probably just look for it, I am sure it is in the code somewhere.

Regards,
David

Reply via email to