Re: Django Postgres Intermediary doesn't set ON DELETE CASCADE

2018-06-25 Thread Simon Charette
Hey James, Just to add to what was already said there's a ticket tracking the addition of database level foreign constraints.[0] Cheers, Simon [0] https://code.djangoproject.com/ticket/21961 Le samedi 23 juin 2018 09:56:23 UTC-4, Tomasz Knapik a écrit : > > If you search about it on the Intern

Re: Django Postgres Intermediary doesn't set ON DELETE CASCADE

2018-06-23 Thread James Bellaby
Indeed! I have actually used the admin site to do it before I posted this it's just something I didn't know was by design. After numerous searches I came here but I may have been asking the wrong questions in google :). The shell would be good if I have quite a few I need to delete. Thankfully

Re: Django Postgres Intermediary doesn't set ON DELETE CASCADE

2018-06-23 Thread Tomasz Knapik
If you search about it on the Internet many sources claim that Django does not set those constraints on the database level. If you look at the code of the base code for database backends, you'll notice that they don't mention on_delete at all. - https://github.com/d jango/django/blob/6dd4edb1b4f54

Re: Django Postgres Intermediary doesn't set ON DELETE CASCADE

2018-06-23 Thread Jason
well, nothing stopping you from doing the same in the django shell and doing `Group.objects.get(pk = some_pk).delete`. that would be an alternative for going straight to the db. I can see some issues with this coming up, especially if you're doing deletes with django's raw sql capability. But

Re: Django Postgres Intermediary doesn't set ON DELETE CASCADE

2018-06-23 Thread James Bellaby
OK. So it's by design. So during development I can't go straight to the database and delete a "Group" quickly due to an error I made. I'd have to set up tests to deal with it at an application level. No probs though. I'm just happy I know it can't be done and not that it's a bug I'd have to wa

Re: Django Postgres Intermediary doesn't set ON DELETE CASCADE

2018-06-23 Thread Melvyn Sopacua
On zaterdag 23 juni 2018 14:40:30 CEST Jason wrote: > Not quite. If you run python manage.py sqlmigrate > , you can see the SQL generated for that migration. > > https://docs.djangoproject.com/en/2.0/ref/django-admin/#django-admin-sqlmigr > ate > > Because Django emulates Cascade, its done outs

Re: Django Postgres Intermediary doesn't set ON DELETE CASCADE

2018-06-23 Thread Jason
Not quite. If you run python manage.py sqlmigrate , you can see the SQL generated for that migration. https://docs.djangoproject.com/en/2.0/ref/django-admin/#django-admin-sqlmigrate Because Django emulates Cascade, its done outside of the db, and therefore shouldn't be a db-level constraint.

Re: Django Postgres Intermediary doesn't set ON DELETE CASCADE

2018-06-23 Thread James Bellaby
OK, understood. However, If you set up CASCADE on the model surely when it creates the table on the database level it surely should set ON DELETE CASCADE not ON DELETE NO ACTION on the CONSTRAINT? On Saturday, 23 June 2018 10:54:44 UTC+1, Melvyn Sopacua wrote: > > On zaterdag 23 juni 2018 00:56:

Re: Django Postgres Intermediary doesn't set ON DELETE CASCADE

2018-06-23 Thread Melvyn Sopacua
On zaterdag 23 juni 2018 00:56:36 CEST James Bellaby wrote: > However when looking are the SQL in Postgresql it's created the Membership > table constraint for the Group id with "ON DELETE NO ACTION" > > CONSTRAINT groups_membership_group_id_d4404a8c_fk_groups_group_id FOREIGN > KEY (group_id) >

Re: Django & Postgres explicit SQL parameters escape

2011-02-21 Thread ju
Thank you On Feb 21, 3:51 pm, Bill Freeman wrote: > Use % escapes in your SQL, but instead of using the % operator to do > the substitution, pass the tuple of values as a second parameter to > cursor execute.  If you tell the db back end that this is a string, by using > %s, then in will quote it

Re: Django & Postgres explicit SQL parameters escape

2011-02-21 Thread Bill Freeman
Use % escapes in your SQL, but instead of using the % operator to do the substitution, pass the tuple of values as a second parameter to cursor execute. If you tell the db back end that this is a string, by using %s, then in will quote it properly so that it won't be interpreted as SQL, so that an

Re: Django, Postgres and recovering from database constraints

2011-02-02 Thread Xavier Ordoquy
ok, thanks a lot. savepoints saved my day :p It just worked out of the box while the other methods didn't seem to work. Back on a more serious topic, could someone confirm or not that the transaction rollback (http://docs.djangoproject.com/en/1.2/topics/db/transactions/#transaction-rollback) d

Re: Django, Postgres and recovering from database constraints

2011-02-01 Thread Xavier Ordoquy
thanks, I'll give it a try tomorrow and let you know. Xavier. Le 1 févr. 2011 à 19:57, Casey S. Greene a écrit : > Also (sorry for the follow-up spam but I just remembered this) if you are > hoping to use the database level autocommit (postgres 8.2 or later), you need > to configure it: > >

Re: Django, Postgres and recovering from database constraints

2011-02-01 Thread Casey S. Greene
Also (sorry for the follow-up spam but I just remembered this) if you are hoping to use the database level autocommit (postgres 8.2 or later), you need to configure it: Autocommit mode New in Django 1.1: Please, see the release notes If your application is particularly read-heavy and doesn’t m

Re: Django, Postgres and recovering from database constraints

2011-02-01 Thread Casey S. Greene
Here is some code pulled from my (using postgres) django application that recovers fine. Perhaps this is helpful to you. I am storing the non-unique values and dealing with them later (pulling from an external source that is supposed to have unique IDs assigned but they don't always pan out s

Re: Django, Postgres and recovering from database constraints

2011-02-01 Thread Xavier Ordoquy
Le 1 févr. 2011 à 15:59, bruno desthuilliers wrote : > On 1 fév, 15:24, Xavier Ordoquy wrote: >> Hi all, >> >> I got a project which sometime outputs database integrity errors (key >> violates unique constraint). >> It is fine since I'm keeping an events table which may have several creation >

Re: Django, Postgres and recovering from database constraints

2011-02-01 Thread bruno desthuilliers
On 1 fév, 15:24, Xavier Ordoquy wrote: > Hi all, > > I got a project which sometime outputs database integrity errors (key > violates unique constraint). > It is fine since I'm keeping an events table which may have several creation > messages for the same object. Hmmm... Either I misunderstood

Re: Django + Postgres

2010-09-01 Thread meitham
> So I have installed postgres, pyscopg2. > > su postgres > created a database > updated my settings.py: > DATABASES = { >     'default': { >         'ENGINE': 'django.db.backends.postgresql_psycopg2', >         'NAME': 'template1', >         'USER': 'postgres', >         'PASSWORD': 'postgres', >

Re: Django + Postgres

2010-08-31 Thread Xavier Ordoquy
Hi, Actually, there is a confusion between the administrative data django fills and the data the admin application owns itself. Unless I'm mistaken, Django admin application only creates 1 table I named in my previous message (django_admin_log). Can you check this table has been created ? If it

Re: Django + Postgres

2010-08-31 Thread Robbington
Apologies I should have been more clear, 'It' refers to my domain name when visited "/admin" All the django settings are correct, I've used sqlite3 and got the admin up and working. So I have installed postgres, pyscopg2. su postgres created a database updated my settings.py: DATABASES = { '

Re: Django + Postgres

2010-08-31 Thread Xavier Ordoquy
Also, what kind of users are you speaking about ? system, database or django users ? Do you have the admin site available in the urls ? Did you uncomment both the url and the auto discovering part ? Did syncdb showed django_admin_log table being created (or can you check it has been created) ?

Re: Django + Postgres

2010-08-31 Thread Albert Hopkins
On Tue, 2010-08-31 at 04:30 -0700, Robbington wrote: > Hi, > > I seem to be having a problem setting up django and postgresql. > > I have created a database and switched users to postgres then sync'd > the database successfully in my django project directory. But it isn't > finding the admin page

Re: Django, Postgres and Core Dumps

2007-07-01 Thread Vikrant
Hi, I am running postgresql with pyscopg2. I have put the details on my blog post at http://www.vyomtech.com/vyomcms/pyscopg2onubuntu64bit.html The essence is first you uninstall your existing python-psycopg2 package. Then install python-dev (in your case it would be 2.5) and then download the ps

Re: Django, Postgres and Core Dumps

2007-05-26 Thread Sam Morris
On Sat, 26 May 2007 19:28:03 +1000, Malcolm Tredinnick wrote: > On Sat, 2007-05-26 at 02:20 -0700, Grant D. Watson wrote: >> Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: >> >> > > In an unusually (for Ubuntu) boneheaded move, it >> > looks >> > > like Ubuntu doesn't leave core files for packaged

Re: Django, Postgres and Core Dumps

2007-05-26 Thread Eugene Morozov
Hello, Here it is: https://bugs.launchpad.net/bugs/108067 I've planned to make a public repository with fixed packages, but I'm too busy for this. Anyway, you can take Feisty package, replace source code with downloaded 2.0.6 source code from psycopg site, bump version number in debian changelog

Re: Django, Postgres and Core Dumps

2007-05-26 Thread Malcolm Tredinnick
On Sat, 2007-05-26 at 12:42 +, Eugene Morozov wrote: > python-psycopg2 package in Ubuntu Feisty for x86-64 is completely > broken. I've reported it in the Launchpad on the next day after > release, but maintainer is still reluctant to apply patch which should > fix 64 bit issues. Ha ha! Probl

Re: Django, Postgres and Core Dumps

2007-05-26 Thread Eugene Morozov
python-psycopg2 package in Ubuntu Feisty for x86-64 is completely broken. I've reported it in the Launchpad on the next day after release, but maintainer is still reluctant to apply patch which should fix 64 bit issues. I've solved the problem by downloading upstream beta version and compiling a

Re: Django, Postgres and Core Dumps

2007-05-26 Thread Grant D. Watson
Of course I omitted the part that might be marginally more useful: (gdb) bt #0 0x00418f22 in ?? () #1 0x00419a10 in PyObject_CallMethod () #2 0x2b062bf4c7e3 in microprotocol_getquoted () from /usr/lib/python2.5/site-packages/psycopg2/_psycopg.so #3 0x2b062bf4e29b in

Re: Django, Postgres and Core Dumps

2007-05-26 Thread Grant D. Watson
--- Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > I think you're a little bit doomed here, if Ubuntu > ships stripped > binaries. On a Fedora system I would install the > *-debuginfo at this > point. Then you could try > > gdb python > ... > (gdb) run manage.py syncdb >

Re: Django, Postgres and Core Dumps

2007-05-26 Thread Malcolm Tredinnick
On Sat, 2007-05-26 at 02:20 -0700, Grant D. Watson wrote: > Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > > > In an unusually (for Ubuntu) boneheaded move, it > > looks > > > like Ubuntu doesn't leave core files for packaged > > > programs, even after a "ulimit -c unlimited". Any > > > other

Re: Django, Postgres and Core Dumps

2007-05-26 Thread Grant D. Watson
Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > In an unusually (for Ubuntu) boneheaded move, it > looks > > like Ubuntu doesn't leave core files for packaged > > programs, even after a "ulimit -c unlimited". Any > > other way to pull this off? > > I wouldn't have thought it was possible to >

Re: Django, Postgres and Core Dumps

2007-05-25 Thread Malcolm Tredinnick
On Fri, 2007-05-25 at 22:46 -0700, Grant D. Watson wrote: > > No idea about the core dump -- it's not very usual > > (for Python). > > Definitely my experience. > > > However, you will have to do something about your > > Python version. Either > > I checked, and as Jeremy said an update was jus

Re: Django, Postgres and Core Dumps

2007-05-25 Thread Grant D. Watson
> No idea about the core dump -- it's not very usual > (for Python). Definitely my experience. > However, you will have to do something about your > Python version. Either I checked, and as Jeremy said an update was just released recently; I've upgraded to 2.5.1. Thanks for the heads-up. > Is

Re: Django, Postgres and Core Dumps

2007-05-25 Thread Jeremy Dunck
On 5/25/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > However, you will have to do something about your Python version. Either > downgrade to 2.5.0 or upgrade to 2.5.1 proper. The problem is that there > was a regression in the 2.5.1-pre-releases with the way dictionary > subclasses are init

Re: Django, Postgres and Core Dumps

2007-05-25 Thread Malcolm Tredinnick
On Fri, 2007-05-25 at 20:51 -0700, Grant D. Watson wrote: > I'm a newbie to Django. It looks amazing, and I've > decided to give it a whirl, but when I try a syncdb on > my new project I get a core dump; the only things I've > changed in settings.py are ADMINS and DATABASE_*. > Given the context

Re: Re: Django, Postgres and Server Crash

2006-10-16 Thread Malcolm Tredinnick
On Mon, 2006-10-16 at 13:45 -0500, James Bennett wrote: > On 10/16/06, Mike <[EMAIL PROTECTED]> wrote: > > The server is rather new. 2GB of memory with a top grade Opteron (not > > sure which). Once again, the server is running with low load for most > > of the day, and as much as I want to, I hav

Re: Re: Django, Postgres and Server Crash

2006-10-16 Thread James Bennett
On 10/16/06, Mike <[EMAIL PROTECTED]> wrote: > The server is rather new. 2GB of memory with a top grade Opteron (not > sure which). Once again, the server is running with low load for most > of the day, and as much as I want to, I have hard time believing its > the server that is to blame. FWIW,

Re: Re: Django, Postgres and Server Crash

2006-10-16 Thread James Bennett
On 10/16/06, Mike <[EMAIL PROTECTED]> wrote: > I just svn update my django directory. Doesn't the latest django > version reflect all the bug fixes? Do I have to check out > 0.91-bugfixes? The "bugfixes" branches are only for the older (0.90 and 0.91) versions of Django, and I only mentioned them

Re: Django, Postgres and Server Crash

2006-10-16 Thread Gary Doades
On Monday 16 October 2006 18:01, Mike wrote: > The server is rather new. 2GB of memory with a top grade Opteron (not > sure which). Once again, the server is running with low load for most > of the day, and as much as I want to, I have hard time believing its > the server that is to blame. But it

Re: Django, Postgres and Server Crash

2006-10-16 Thread Tim Chase
> Pressing 'c' on top clears everything a little bit. One thing > I think I forgot to mention is 90% of the time the server load > is moderate. It is 3 times a week around early in the morning > that my django and postgres start dancing to death for me. > Given that my server hardware handles the

Re: Django, Postgres and Server Crash

2006-10-16 Thread Mike
> What are the specs of the server? Specifically, how much RAM does it > have and how fast are its disks? What processors are in the machine > (for postgres, Xeons are bad, Opterons are very, very good)? The server is rather new. 2GB of memory with a top grade Opteron (not sure which). Once agai

Re: Django, Postgres and Server Crash

2006-10-16 Thread Mike
James, Thanks for your response. I just svn update my django directory. Doesn't the latest django version reflect all the bug fixes? Do I have to check out 0.91-bugfixes? Pressing 'c' on top clears everything a little bit. One thing I think I forgot to mention is 90% of the time the server load

Re: Re: Django, Postgres and Server Crash

2006-10-16 Thread James Bennett
On 10/16/06, Siah <[EMAIL PROTECTED]> wrote: > I tried increasing the number of postgres connections, and it ended up > completely killing the server. The server I'm working with has 2 django > sites running, one of which receives around 3M hits a month. The other > one somewhere around 200K hits,

Re: Django, Postgres and Server Crash

2006-10-16 Thread Siah
Per connection? Does it mean per request, or page view? I tried increasing the number of postgres connections, and it ended up completely killing the server. The server I'm working with has 2 django sites running, one of which receives around 3M hits a month. The other one somewhere around 200K h

Re: Django, Postgres and Server Crash

2006-10-16 Thread James Bennett
On 10/16/06, Siah <[EMAIL PROTECTED]> wrote: > How many postmaster instances should be running at once? Also, if you're running an older version of Django, be sure to update to the "bugfixes" branch for it; the mod_python handler had a bug in it which could leak DB connections, and which has sinc

Re: Django, Postgres and Server Crash

2006-10-16 Thread James Bennett
On 10/16/06, Siah <[EMAIL PROTECTED]> wrote: > How many postmaster instances should be running at once? Are you talking about 'postmaster', or 'postgres'? The default behavior of top has a nasty habit of confusing the two; press 'c' to have it show the full info. That said, we have a bunch of po

Re: Django, Postgres and Server Crash

2006-10-16 Thread [EMAIL PROTECTED]
Postgres uses one process per connection. How many simultaneous connections have you got in total? If you don't have that many simultaneous users then you may not be closing database connections somewhere. You can increase the number of connections that Postgres can handle, but it looks like you