Hi Malcolm,

On Mon, Jul 21, 2008 at 10:45 PM, Malcolm Tredinnick <
[EMAIL PROTECTED]> wrote:

>
> On Mon, 2008-07-21 at 21:23 -0700, s wrote:
>
> I'm trying to create a dynamic export mechanism (pretty simple) but
> > also trying to export a schema file for the parties wishing to re-
> > import, said-export, with better insight.
>


> Some of your words could have multiple meanings, so it's hard to know
>
exactly what you're asking. Do you mean that you're trying to export the
> database schema for these models? In that case, you could try to use
> what django.core.management.sql.sql_create() would return when you pass
> it the right parameters.
>

Well, I wasn't looking specifically for the SQL, but the
mechanisms effectively used to inspect the model(s) and subsequently
generate the SQL.

After a quick look at ...sql_create(), I see that
django.db.models.loading.py and
django.core.management.sql._get_sql_model_create() have the pieces I'm
looking for.

An interesting bit will be to see if I can do this from within a model or if
it will be easier as a separate util. I'm trying to make each model
responsible for the export of its own data (but not the marking to disk,
etc.). This is because the users can sub-select fields from within each
model, so the list - even the order, is somewhat dynamic.

If that isn't what you mean, a little more context will help us to help
> you.


It gives me a good place to look, without wasting too much valuable time of
others.

For better insight, here's hopefully a better explanation of what I'm
wishing to do:

Example model:

    class dummy_model(models.Model):
        name = models.CharField(maxlength=64)
        active = models.BooleanField()
        fav_color = models.CharField(max_length=16
        ...

Exported data:
    "Fred",True,"red"
    "Jane",True,"green"
    "Bob",False,"pink"

I wish to create a file containing:
    Field    Type    Length
    name   string    64
    active   bool      1
    fav_color   string    16
    ...

Of course, I'd have to do something different for calculated values (from
methods).

Thanks for the info, much appreciated!

/S

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to