Re: What actually happens during syncdb?

2012-05-07 Thread Python_Junkie
Syncdb utility is a (very) convenient tool for converting the database model 
from models.py to the physical structure creation in the actual database. 
You can create the physical model without using Syncdb at all if u are 
comfortable with SQL. 
That said, when the admi site tries to read and writ SQL using theORM , the 
model is used by the ORM to understand how to read and write to 

If u do not want to use the ORM the model is of no use. The models.py is an 
interface for the ORM

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/H8BtAJebxP0J.
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.



Re: What actually happens during syncdb?

2012-05-07 Thread Matt Schinckel
I'll preface this by saying I work with postgres, so some syntax stuff may 
be different.

To work within a different schema, you just need to tell the database to 
use that schema as part of the connection process. In postgres, this means 
issuing the command:

SET search_path TO schema;

I'm currently working through a project that allows for multiple schemata, 
and do this before re-running parts of the database table creation process, 
but this is almost certainly overkill for what you want.

https://bitbucket.org/schinckel/django-multi-schema/

Matt.

On Tuesday, May 8, 2012 12:27:01 AM UTC+9:30, Cass wrote:
>
> Hey!
>
> Django newbie here.
>
> I built out a django admin site that's up and running using a SQL Server 
> database. I now want to convert the tables that django generated for my 
> models over to a different database schema. 
>
> Here was my process and there are probably a couple missteps in here:
>
> 1) I modified models.py so that db_table = 'schema].[tablename' (hack?)
> 2) I ran syncdb after altering models.py, but syncdb complained saying 
> that the syntax was wrong during the index creation step.
> 3) I looked at the sql it was using to create indices, and it was indeed 
> wrong. My hack was causing it to try to create indices named 
> [schema].[indexname]. I changed the sql so that the indices to create would 
> just be called [indexname], and then ran this code directly on the 
> database. 
>
> At this point, I felt like everything should be okay given that the state 
> of the database and the state of models.py are theoretically synced up. 
> (however, syncdb never ran successfully because of the index problem).
>
> I restart my Apache instance, and go to the admin site expecting to see my 
> newly created blank tables reflected in the interface (i.e. no data). 
> However, I actually see all my old data! This is strange, because models.py 
> no longer references the old tables.
>
> I was wondering, am I doing something silly or does syncdb actually do 
> something behind the scenes and needs to complete successfully before my 
> changes are reflected?  
>
> After noticing that my changes were not reflected, I tried running syncdb 
> again. But this time syncdb didn't even make it past the table creation 
> step, hiccuping that the table has already been created.
>
> Thanks so much for your help!
>
> Cassandra
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/acLOdCiRniwJ.
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.



What actually happens during syncdb?

2012-05-07 Thread Cassandra Xia
Hey!

Django newbie here.

I built out a django admin site that's up and running using a SQL Server
database. I now want to convert the tables that django generated for my
models over to a different database schema.

Here was my process and there are probably a couple missteps in here:

1) I modified models.py so that db_table = 'schema].[tablename' (hack?)
2) I ran syncdb after altering models.py, but syncdb complained saying that
the syntax was wrong during the index creation step.
3) I looked at the sql it was using to create indices, and it was indeed
wrong. My hack was causing it to try to create indices named
[schema].[indexname]. I changed the sql so that the indices to create would
just be called [indexname], and then ran this code directly on the
database.

At this point, I felt like everything should be okay given that the state
of the database and the state of models.py are theoretically synced up.
(however, syncdb never ran successfully because of the index problem).

I restart my Apache instance, and go to the admin site expecting to see my
newly created blank tables reflected in the interface (i.e. no data).
However, I actually see all my old data! This is strange, because models.py
no longer references the old tables.

I was wondering, am I doing something silly or does syncdb actually do
something behind the scenes and needs to complete successfully before my
changes are reflected?

After noticing that my changes were not reflected, I tried running syncdb
again. But this time syncdb didn't even make it past the table creation
step, hiccuping that the table has already been created.

Thanks so much for your help!

Cassandra

-- 
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.