Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Dec. 16, 2010 14:16:30

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

use table not in the model


Hello
i like to use some database table that are not in my models.py
in fact some of table will be add and remove by script

is it possible to use some sql queries with it ? on not at all ?

regards

tonton

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Dec. 16, 2010 14:38:43

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

use table not in the model


On Dec 16, 7:16 am, Tonton <to.ton...@gmail.com> wrote:
> Hello
> i like to use some database table that are not in my models.py
> in fact some of table will be add and remove by script
>
> is it possible to use some sql queries with it ? on not at all ?
>
> regards
>
> tonton

Hello Tonton,

Yes, you have full access to SQL if you need it regardless of whether
django know about the tables or not. You can also create a model for
your table as long as the schema is the same, look at inspectdb,
django doesn't care how the table was created. I have used views to
aggregate date that I only need read only queries and made a model for
the view then set all columns to have editable = False to keep admin
etc from trying to update.

Mark

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Dec. 16, 2010 14:44:47

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

use table not in the model


On 16 déc, 15:16, Tonton <to.ton...@gmail.com> wrote:
> Hello
> i like to use some database table that are not in my models.py
> in fact some of table will be add and remove by script
>
> is it possible to use some sql queries with it ?

Of course it is.

>>> from django.db import connection
>>> cursor = connection.cursor()
>>> cursor.execute("create table foo(id integer auto_increment primary key,
>>> title varchar(30))")
0L
>>> for title in ("foo", "bar", "baaz"):
... cursor.execute("insert into foo(title) values(%s)", (title,))
...
1L
1L
1L
>>> cursor.execute("select * from foo")
3L
>>> for row in cursor:
... print row
...
(1L, u'foo')
(2L, u'bar')
(3L, u'baaz')
>>> cursor.execute("drop table foo")
0L
>>>

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#4 Dec. 16, 2010 15:02:29

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

use table not in the model


Tonton ...

See <http://docs.djangoproject.com/en/1.2/topics/db/sql/> for details on how
to use so-called 'raw' SQL (ie: not managed with models) within Django.

- Craig -

On Thu, Dec 16, 2010 at 09:16, Tonton <to.ton...@gmail.com> wrote:

> Hello
> i like to use some database table that are not in my models.py
> in fact some of table will be add and remove by script
>
> is it possible to use some sql queries with it ? on not at all ?
>
> regards
>
> tonton
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
>http://groups.google.com/group/django-users?hl=en.
>

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#5 Dec. 16, 2010 15:36:38

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

use table not in the model


thanks for yours ansewers i wiil read that

i try this

def getExtentFromaMap(amap):
idx =
e=
listcouche = get_list_or_404(Layer, carte_id=amap.id)
for l in range(len(listcouche)):
x=listcouche.dataset_id
idx.append (x)
for ds in range(len(idx)):
y = idx.sourcetable
cursor=connection.cursor()
cursor.execute("""SELECT st_find_extent(y,'geometry')from courly""")
p=row
e.append (p)
return e

sure it is not work but i am interest to use function and it seems possible
but how to use varaible ine the request ?
here it is my table name store in y

:)

On Thu, Dec 16, 2010 at 4:02 PM, W. Craig Trader <craig.tra...@gmail.com>wrote:

> Tonton ...
>
> See <http://docs.djangoproject.com/en/1.2/topics/db/sql/> for details on
> how to use so-called 'raw' SQL (ie: not managed with models) within Django.
>
> - Craig -
>
> On Thu, Dec 16, 2010 at 09:16, Tonton <to.ton...@gmail.com> wrote:
>
>> Hello
>> i like to use some database table that are not in my models.py
>> in fact some of table will be add and remove by script
>>
>> is it possible to use some sql queries with it ? on not at all ?
>>
>> regards
>>
>> tonton
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>>http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
>http://groups.google.com/group/django-users?hl=en.
>

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 17th of August
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