ds99 wrote:
> No that table name will be different every time based on some id. If
> table name is same then there is no problem but the issue arises when
> table names are different but the schema is same.
>
> On May 26, 3:51 pm, Ankit <ankit....@mkhoj.com> wrote:
>   
>> ds99 wrote:
>>     
>>> Hi Ankit,
>>> I got what you are saying. I'll tell you what I want to do.
>>>       
>>> For eg: For one request one process creates table called "books_111"
>>> and after its purpose is done, whole table will be dropped. It may
>>> also happen that while this table is being worked upon, another table
>>> with same schema is created for another request. Now to access this
>>> table using django APIs, i need to have latest snapshot of the
>>> database,i.e, updated model file. For that again we need to fire
>>> "python manage.py inspectdb" to create missing models. Is there any
>>> other way to do it on the fly?
>>>       
>>> Thanks,
>>> ds99
>>>       
>>> On May 26, 3:11 pm, Ankit <ankit....@mkhoj.com> wrote:
>>>       
>>>> ds99 wrote:
>>>>         
>>>>> Hi Alex,
>>>>> Thanks a lot or quick reply. A couple of queries below:
>>>>>           
>>>>> 1) How can this be handled when the tables are created dynamically?
>>>>> Actually the tables will be created dynamically by some other process
>>>>> and will be deleted after its purpose is over. So is there any other
>>>>> way or we need to call python script with inspectdb everytime we get a
>>>>> new request?
>>>>>           
>>>>> 2) This is possible for only one database as it would inspect database
>>>>> pointed by DATABASE_NAME setting and create models. Can this be done
>>>>> if we have one database per session?
>>>>>           
>>>>> Thanks again,
>>>>> ds99
>>>>>           
>>>>> On May 26, 8:13 am, Alex Gaynor <alex.gay...@gmail.com> wrote:
>>>>>           
>>>>>> On Mon, May 25, 2009 at 10:07 PM, ds99 <cozydarsh...@gmail.com> wrote:
>>>>>>             
>>>>>>> Hi,
>>>>>>> I am new to django.I have a requirement where in have to access tables
>>>>>>> which are not created using django models, using django APIs.
>>>>>>>               
>>>>>>> For eg: I already have tables "book_111" and "book_222" created in
>>>>>>> sqlite db by some different process. Both having same schema.I want to
>>>>>>> access them to retrieve records using django database APIs. How can i
>>>>>>> do that?
>>>>>>> Do i need to add their schema in models.py? Can one model be used to
>>>>>>> refer to multiple tables in database?
>>>>>>>               
>>>>>>> Please let me know.
>>>>>>>               
>>>>>>> Thanks,
>>>>>>> ds99
>>>>>>>               
>>>>>> Yes, you can use those models with django, you'll need to create Model
>>>>>> classes for them 
>>>>>> though,http://docs.djangoproject.com/en/dev/ref/django-admin/#inspectdbcanas...
>>>>>> with this task.  No one model can't be used to refer to multiple tables.
>>>>>>             
>>>>>> Alex
>>>>>>             
>>>>>> --
>>>>>> "I disapprove of what you say, but I will defend to the death your right 
>>>>>> to
>>>>>> say it." --Voltaire
>>>>>> "The people's good is the highest law."--Cicero
>>>>>>             
>>>>> .
>>>>>           
>>>> hi
>>>>         
>>>>     If there is table in the database you are connected to django will
>>>> not create a new one.If you are using django1.1 you can manually set
>>>> whether to create a table or not in the db(manged option in class
>>>> meta).Is complete table is being drop or only the data is being
>>>> deleted.what you to do with these tables.Explanation is required.
>>>>         
>>> .
>>>       
>> See first of all table name will be same.Django displays latest data of
>> the table only.If the table content has been changed then it will the
>> latest one but the schema of the table should be same as
>> before.According to you a table is created on request by some thing for
>> that you can have a cron that will change the content of the table after
>> specific time so that your work is not intrupt.
>>     
> >
> .
>
>   
If table name is different then God Save you.But still you can have db 
query which can fetch data for you.Or make a model which have the table 
name or id generated and then in ur previous model have foregnkey on the 
new model.means model 1 will have list of tables and model 2 will have 
foreignkey on model 1

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to