Thank you Niphold for your time and patience. So actually there isnt any
particular benefit in writing in a dump file and loading. Its better to
write these definitions in another db.py (like mydb.py) file and load. Then
I would be able to get it in the db.py. Thanks
On Friday, 16 August 2013 19:56:29 UTC+5:30, Niphlod wrote:
>
> Again, web2py shell doesn't know anything that is not in your models.
> Whatever dump you loaded into your database, web2py doesn't know anything
> about it.
> Web2py can only access what you set in your db.py: of course what is there
> must match what is in the database, because at the first time you'll try to
> select() data from those tables, if column names and types don't match, an
> exception will be raised.
>
> On Friday, August 16, 2013 4:10:35 PM UTC+2, ajith c t wrote:
>>
>> Ok thanks. Just one more thing, so if there are around 10 tables in my
>> dump file which is loaded into the database and I have set migrate = False,
>> as I dont make any modifications or table alterations in the db.py. How can
>> I get these tables listed in the db.tables command in the web2py shell. Its
>> really confusing me. I ran my app with migrate = False, since the table
>> definitions are all there in dump file. But in the web2py shell it just
>> shows the auth_tables with the default declerations only.
>>
>> On Friday, 16 August 2013 19:18:56 UTC+5:30, Niphlod wrote:
>>>
>>> that's basically the deal. Either you let web2py manage the database
>>> (migrate=True), or you do it by hand (migrate=False). There's no need to
>>> have migrate=True unless you modified your models, and in fact in
>>> production is recommended to turn migrations off to gain speed. But what
>>> you see in web2py is always only relative to your code, because web2py
>>> doesn't engage in any kind of "introspection" of what tables really are in
>>> your backend.
>>>
>>> On Friday, August 16, 2013 3:30:18 PM UTC+2, ajith c t wrote:
>>>>
>>>> so does that mean if I add the changes for default auth table
>>>> definition in my db.py file with respect to the auth table in the dump
>>>> file, then only it will be reflected in the web2py shell. And once both
>>>> the
>>>> definitions matches then there is no need migration also.
>>>> The change is only in the auth_user table. So I will have to add extra
>>>> fields to the t_auth_users tables in db.py.
>>>>
>>>>
>>>>
>>>> On Friday, 16 August 2013 18:40:47 UTC+5:30, Niphlod wrote:
>>>>>
>>>>> web2py shell shows you your tables as they are defined in models. What
>>>>> is there on the database usually matches (when migrate=True or when
>>>>> you're
>>>>> totally and absolutely sure that your models match the underlying table
>>>>> definitions).
>>>>> If you see in web2py shell something different from your underiyng
>>>>> tables, then the "difference" is to be found in your models, meaning that
>>>>> your table definitions DON'T match your underlying schema.
>>>>>
>>>>> On Friday, August 16, 2013 2:43:22 PM UTC+2, ajith c t wrote:
>>>>>>
>>>>>> Ok I tried the first request with fake_migrate = True, then
>>>>>> everything works fine. The app runs. I open the web2py shell and run the
>>>>>> db.tables command it list the default auth tables only, with the
>>>>>> customized names.
>>>>>> But these tables contains only the default auth fields in it, but in
>>>>>> my dump file I have quite a number of fields.
>>>>>> I then remove the fake_migrate argument and run the app. The same
>>>>>> result is found. Only the default fields are there with the values.
>>>>>>
>>>>>> Isnt the web2py shell supposed to show all the fields in the database.
>>>>>>
>>>>>> On Friday, 16 August 2013 17:57:57 UTC+5:30, Niphlod wrote:
>>>>>>>
>>>>>>> if your models match the tables you're creating on mysql manually,
>>>>>>> then what do you need migration for ?
>>>>>>> set migrate=False ... you did manually what web2py usually does
>>>>>>> automatically.
>>>>>>> I'd also use fake_migrate=True for the first request (then remove
>>>>>>> it) just to update the relevant .table files in the databases/* folder.
>>>>>>>
>>>>>>> On Friday, August 16, 2013 2:25:13 PM UTC+2, ajith c t wrote:
>>>>>>>>
>>>>>>>> So does that mean I dont have to specify any migrate keyword? I
>>>>>>>> just have a file with custom auth table definitons and need to use it.
>>>>>>>>
>>>>>>>> On Friday, 16 August 2013 17:49:29 UTC+5:30, Niphlod wrote:
>>>>>>>>>
>>>>>>>>> if you create your tables you can't enable migrations in web2py,
>>>>>>>>> 'cause web2py will try to create them.
>>>>>>>>>
>>>>>>>>> On Friday, August 16, 2013 2:11:44 PM UTC+2, ajith c t wrote:
>>>>>>>>>>
>>>>>>>>>> Hi,
>>>>>>>>>> I have defined my auth_tables in a mysql file along
>>>>>>>>>> with some initial row for my app. The name of this file is '*
>>>>>>>>>> dump.sql*'.
>>>>>>>>>>
>>>>>>>>>> I have renamed the tables, for example auth_users is changed to
>>>>>>>>>> t_auth_users, similarly the other auth_tables too.
>>>>>>>>>>
>>>>>>>>>> So when the app is hosted the db is created from this file.
>>>>>>>>>>
>>>>>>>>>> In the db.py file before the db.define_tables(), i have renamed
>>>>>>>>>> the auth_tables, for example:
>>>>>>>>>>
>>>>>>>>>> *auth.settings.table_user_name = 't_auth_users' *
>>>>>>>>>>
>>>>>>>>>> and similarly others too. My question is how to efficiently
>>>>>>>>>> handle this migration. I cannot get my auth tables modified
>>>>>>>>>> according to
>>>>>>>>>> the defintion in the dump.sql file.
>>>>>>>>>>
>>>>>>>>>> Instead the table is created with default fields only. I have
>>>>>>>>>> around 20 fields for the t_auth_users table in dump.sql but only the
>>>>>>>>>> 9
>>>>>>>>>> defaults fields can be seen in webp2y shell db.t_auth_users command.
>>>>>>>>>>
>>>>>>>>>> this is the order:
>>>>>>>>>>
>>>>>>>>>> 1. First I clear all the files in databases folder for a fresh
>>>>>>>>>> start.
>>>>>>>>>> 2. Then load the dump.sql file into the database '*tv*'
>>>>>>>>>> 3. in db.py
>>>>>>>>>> *db = DAL('mysql://root:root@localhost/trustvouch',
>>>>>>>>>> migrate=True)*
>>>>>>>>>> * *
>>>>>>>>>> * auth.settings.table_user_name = 't_auth_users'*
>>>>>>>>>> * *
>>>>>>>>>> * **auth.define_tables(username=True, migrate=True)*
>>>>>>>>>> 4. It give me this error,
>>>>>>>>>> * <class '_mysql_exceptions.OperationalError'> (1050,
>>>>>>>>>> "Table 'tv_auth_users' already exists")*
>>>>>>>>>> *
>>>>>>>>>> *
>>>>>>>>>> *
>>>>>>>>>> *
>>>>>>>>>> Can you help how to get the correct migration of the tables.
>>>>>>>>>>
>>>>>>>>>> What I actually need to do is load my table definitions from
>>>>>>>>>> another mysql dump file , use the tables defined there as my auth
>>>>>>>>>> tables.
>>>>>>>>>>
>>>>>>>>>> *
>>>>>>>>>> *
>>>>>>>>>>
>>>>>>>>>>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.