Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Nov. 14, 2005 18:56:57

p.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Creating new tables


Hi,

is it possible to create new tables not specified in the model at
runtime?
If yes then
a. how can you do that?
b. can the new tables be accessed using the database API?

Thank you very much
Best Regards

Panos

Offline

#2 Nov. 15, 2005 04:12:30

Kenneth G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Creating new tables


On Tuesday 15 Nov 2005 12:26 am, panos wrote:
> Hi,
>
> is it possible to create new tables not specified in the model at
> runtime?

yes, but why?

> If yes then
> a. how can you do that?

access the database directly - not through django

> b. can the new tables be accessed using the database API?

no
--
regards
kghttp://www.livejournal.com/users/lawgontally ho!http://avsap.org.inಇಂಡ್ಲಿನಕ್ಸ வாழ்க!

Offline

#3 Nov. 15, 2005 04:45:08

Tom T.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Creating new tables


On 11/14/05, Kenneth Gonsalves <> wrote:
>
> On Tuesday 15 Nov 2005 12:26 am, panos wrote:
> > b. can the new tables be accessed using the database API?
>
> no

Not true; you can set up a model to deal with a database created by
hand (although I'm not sure why you'd want to *purposely* create a
database for Django by hand; it does a good job of taking care of that
for you). Now, if you want to *change* your model later on -- that's
where you're forced to do things manually.

Offline

#4 Nov. 15, 2005 05:39:13

Kenneth G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Creating new tables


On Tuesday 15 Nov 2005 10:14 am, Tom Tobin wrote:
> On 11/14/05, Kenneth Gonsalves <> wrote:
> > On Tuesday 15 Nov 2005 12:26 am, panos wrote:
> > > b. can the new tables be accessed using the database API?
> >
> > no
>
> Not true; you can set up a model to deal with a database created by
> hand (although I'm not sure why you'd want to *purposely* create a
> database for Django by hand; it does a good job of taking care of
> that for you).

what i meant was that unless you have a model, you cannot access the
table through django - it is irrelevant whether the model came first or
the table came first.
--
regards
kghttp://www.livejournal.com/users/lawgontally ho!http://avsap.org.inಇಂಡ್ಲಿನಕ್ಸ வாழ்க!

Offline

#5 Nov. 15, 2005 05:53:43

Tom T.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Creating new tables


On 11/15/05, Kenneth Gonsalves <> wrote:
> > Not true; you can set up a model to deal with a database created by
> > hand (although I'm not sure why you'd want to *purposely* create a
> > database for Django by hand; it does a good job of taking care of
> > that for you).
>
> what i meant was that unless you have a model, you cannot access the
> table through django - it is irrelevant whether the model came first or
> the table came first.

Ahh, then panos is asking for strange behavior. :-)

Offline

#6 Nov. 15, 2005 08:09:44

p.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Creating new tables


I don't know if it is strange or not, but it came to me as a natural
choice for my application.
Think of a logging application where some variables need to be logged
and we need a table for
each variable holding a great number of "timestamp - value" entries.
The thing is we don't know beforehand which variables we need to log,
but the app user specifies that dynamicaly. These variables
could be hundreds or even thousands so it doesn't make sense to create
a table at the beginning
for each and every one of them. I want to be able to create a new table
at runtime as soon as a new
variable is selected for logging.

Offline

#7 Nov. 15, 2005 08:16:49

Kenneth G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Creating new tables


On Tuesday 15 Nov 2005 1:39 pm, panos wrote:
> I don't know if it is strange or not, but it came to me as a natural
> choice for my application.
> Think of a logging application where some variables need to be logged
> and we need a table for
> each variable holding a great number of "timestamp - value" entries.
> The thing is we don't know beforehand which variables we need to log,
> but the app user specifies that dynamicaly. These variables
> could be hundreds or even thousands so it doesn't make sense to
> create a table at the beginning
> for each and every one of them. I want to be able to create a new
> table at runtime as soon as a new
> variable is selected for logging.

this is actually an sql issue - but you need two tables:

table log:
fields: id, variablename

table logdetails:
fields: id, foreignkey(variablename), timestamp, logentry

every new variable is added to 'log' table and log entries for it go in
the 'logentry' table.

--
regards
kghttp://www.livejournal.com/users/lawgontally ho!http://avsap.org.inಇಂಡ್ಲಿನಕ್ಸ வாழ்க!

Offline

#8 Nov. 15, 2005 08:18:06

Jeremy D.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Creating new tables


On 11/15/05, panos <> wrote:
>
> I don't know if it is strange or not, but it came to me as a natural
> choice for my application.
> Think of a logging application where some variables need to be logged
> and we need a table for
> each variable holding a great number of "timestamp - value" entries.

So why not a table w/ 3 columns: timestamp, type, value? Hot spots?

Offline

#9 Nov. 15, 2005 09:05:54

p.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Creating new tables


Well I have thought about that but there are some issues.
First of all the table "logdetails" will become huge. Imagine logging
values of 5000 variables
every 15minutes!
Secondly not all variables are of the same time. They can be boolean,
int and real.
If you have just one table for all of them then logentry has to be the
"biggest" type namely
real to accomodate all of them But isn't that a great waste of space
storing a boolean
with 4 or 8 bytes?

Offline

#10 Nov. 15, 2005 09:12:58

Jeremy D.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Creating new tables


On 11/15/05, panos <> wrote:
>
> Well I have thought about that but there are some issues.
> First of all the table "logdetails" will become huge. Imagine logging
> values of 5000 variables
> every 15minutes!
> Secondly not all variables are of the same time. They can be boolean,
> int and real.
> If you have just one table for all of them then logentry has to be the
> "biggest" type namely
> real to accomodate all of them But isn't that a great waste of space
> storing a boolean
> with 4 or 8 bytes?

It sounds to me like you're complaining that a relational database
isn't the right tool for your job.

Offline

Board footer

Moderator control

Enjoy the 18th of November
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support