Quantcast

Upload a excel table, generate model at run time and save it to database

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Upload a excel table, generate model at run time and save it to database

sivakumar.dk

I like to create a site where users upload their excel (1 or many) and use the platform to query the data anytime they login.

So can someone help how can i do the below:


1. How can i create a model for any excel table or shapefile at run time and build ORM before saving it to database? Because its not possible to imagine the column names and their data types.


2. Also , like to know a simple strategy of loading those tables in database instead of loading each imported excel table as different table in the database.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/07f053aa-508f-450c-946a-0b3fcfdbdff4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Upload a excel table, generate model at run time and save it to database

Christian Ledermann
I have some ancient, unfinished proof of concept  code lying around in
https://github.com/cleder/kotti_rdbt and https://github.com/cleder/geo_ko
It uses Pyramid/kotti rather than django.

It handled shapefiles and dBase file upload and converts them to
sqlalchemy tables

On 21 April 2017 at 07:39,  <[hidden email]> wrote:

> I like to create a site where users upload their excel (1 or many) and use
> the platform to query the data anytime they login.
>
> So can someone help how can i do the below:
>
>
> 1. How can i create a model for any excel table or shapefile at run time and
> build ORM before saving it to database? Because its not possible to imagine
> the column names and their data types.
>
>
> 2. Also , like to know a simple strategy of loading those tables in database
> instead of loading each imported excel table as different table in the
> database.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> To post to this group, send email to [hidden email].
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/07f053aa-508f-450c-946a-0b3fcfdbdff4%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Best Regards,

Christian Ledermann

Newark-on-Trent - UK
Mobile : +44 7474997517

https://uk.linkedin.com/in/christianledermann
https://github.com/cleder/


<*)))>{

If you save the living environment, the biodiversity that we have left,
you will also automatically save the physical environment, too. But If
you only save the physical environment, you will ultimately lose both.

1) Don’t drive species to extinction

2) Don’t destroy a habitat that species rely on.

3) Don’t change the climate in ways that will result in the above.

}<(((*>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABCjzWoX%3D868zYjoeiRRCBOPuma6tSixY0DrbE7xwdTVVzF5GA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Upload a excel table, generate model at run time and save it to database

Antonis Christofides-2
In reply to this post by sivakumar.dk

Although it may be possible, you are not supposed to be creating models on the fly. This isn't peculiar to Django; it violates the good practices of relational database systems. You may be able to accomplish what you want with something like this:

class Spreadsheet(models.Model):
    user = ...
    ...


class Cell(models.Model):
    spreadsheet = models.ForeignKey(Spreadsheet)
    row = models.PositiveIntegerField()
    column = models.PositiveIntegerField()
    content = models.TextField(blank=True)

    class Meta:
        unique_together = (spreadsheet, row, column)

Regards,

A.

Antonis Christofides
http://djangodeployment.com
On 2017-04-21 09:39, [hidden email] wrote:

I like to create a site where users upload their excel (1 or many) and use the platform to query the data anytime they login.

So can someone help how can i do the below:


1. How can i create a model for any excel table or shapefile at run time and build ORM before saving it to database? Because its not possible to imagine the column names and their data types.


2. Also , like to know a simple strategy of loading those tables in database instead of loading each imported excel table as different table in the database.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/07f053aa-508f-450c-946a-0b3fcfdbdff4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/428613e0-b580-aa58-301f-de3f96be3bed%40djangodeployment.com.
For more options, visit https://groups.google.com/d/optout.
Loading...