Re: Postgres and backup/restore

2014-02-06 Thread Simon Riggs
On 7 February 2014 00:31, Mike Dewhirst  wrote:
> On 7/02/2014 10:07am, Lachlan Musicman wrote:
>>
>> Hola,
>>
>> What are people's recommendations for postgres db backup solutions?
>>
>> I've just installed django-dbbackup and will give it a try, but
>> thought I'd ask what others were using.
>
>
> Daily dump to a file which is backed up across the network.
>
> http://www.postgresql.org/docs/9.3/static/app-pgdump.html
>
> I'm planning to do something clever with the transaction log continuously
> writing it to another machine but I haven't done that yet.
>
> One day real soon now.

Today is good. Streaming replication does exactly that.

http://www.postgresql.org/docs/9.3/static/warm-standby.html#STREAMING-REPLICATION

-- 
 Simon Riggs   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BU5nMLJ6AbC7AdF5ixV0ni_HPfzEZ2XpmPwXoKRdwV2vnSQDA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Representing infinity or "no limit" in an integer field?

2013-08-20 Thread Simon Riggs
On 20 August 2013 11:46, Jani Tiainen  wrote:

> I think pretty latest PostgreSQL can use indexes to filter NULL values as 
> well (doesn't have facility to store them though).

Postgres can use an index to find NULL values, so SELECT * FROM foo
WHERE col IS NULL can be indexed.

Not sure what you mean by "doesn't have facility to store them". NULL
values are stored in the database, they just don't occupy the same
space as non-NULL values. PostgreSQL's support of NULL values is full
and complete, in line with SQL Standard requirements.

> MySQL uses table statistics to determine are NULL values indexed or not.

Postgres stats include number of values NULL.

-- 
 Simon Riggs   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: data transfer between databases

2013-07-01 Thread Simon Riggs
On 2 July 2013 05:49, Mike Dewhirst  wrote:

> On Monday, July 1, 2013 10:32:53 PM UTC+10, si...@2ndquadrant.com wrote:
>
>> On 1 July 2013 13:02, Mike Dewhirst  wrote:
>>
>>
>>> On 1/07/2013 9:35pm, Tom Evans wrote:
>>>
>>>> On Sun, Jun 30, 2013 at 11:24 PM, Mike Dewhirst 
>>>> wrote:
>>>>
>>>>> mulianto and Avraham
>>>>>
>>>>> Thanks for your suggestions. Dumping data isn't the entire problem -
>>>>> which
>>>>> is this:
>>>>>
>>>>> There will be an *ongoing* need to add new data from tables in one
>>>>> database
>>>>> to the same-named tables in another database on a remote machine. Two
>>>>> of the
>>>>> tables are in a m2m relationship.
>>>>>
>>>>>
>> You can use direct access via "foreign tables" the name of the Postgres
>> distributed database feature.
>> http://www.postgresql.org/**docs/devel/static/sql-**
>> createforeigntable.html<http://www.postgresql.org/docs/devel/static/sql-createforeigntable.html>
>>
>
> Simon
>
> I read the 
> sql-**createforeigntable<http://www.postgresql.org/docs/devel/static/sql-createforeigntable.html>
>  page
> and I think I know what a distributed database is versus a replicated
> database. But I have no idea why I would choose one over the other. Can you
> suggest?
>

Distributed access is more dynamic but likely somewhat slower when access
required. Replication could be thought of as pre-cacheing the data you want
to see.


> In any case, I'm 99% sure I should "refactor" (if that's the right word)
> the reference tables out of the database into a separate database and get
> to that data via a Django router.
>

Why take them out and then bring them back in? Why not leave where they are
and copy elsewhere?


> Not sure how I'll do that just yet but it has to come ahead of a
> distribute/replicate solution.
>

-- 
 Simon Riggs   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: data transfer between databases

2013-07-01 Thread Simon Riggs
On 1 July 2013 13:02, Mike Dewhirst  wrote:


> On 1/07/2013 9:35pm, Tom Evans wrote:
>
>> On Sun, Jun 30, 2013 at 11:24 PM, Mike Dewhirst 
>> wrote:
>>
>>> mulianto and Avraham
>>>
>>> Thanks for your suggestions. Dumping data isn't the entire problem -
>>> which
>>> is this:
>>>
>>> There will be an *ongoing* need to add new data from tables in one
>>> database
>>> to the same-named tables in another database on a remote machine. Two of
>>> the
>>> tables are in a m2m relationship.
>>>
>>>
You can use direct access via "foreign tables" the name of the Postgres
distributed database feature.
http://www.postgresql.org/docs/devel/static/sql-createforeigntable.html

-- 
 Simon Riggs   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: new to Django and building web applications. Advice with postgresql

2013-05-21 Thread Simon Riggs
On 21 May 2013 15:00, Tom Evans  wrote:

> The only queries you need to rewrite on moving django/sqlite ->
> django/postgres are raw queries. How many will this beginner have?
> Should rewriting raw queries be the thing this beginner worries about?
>
> 'YMMV' indeed. Switching or changing DB engines in a Django app is not
> hard, unless the app is extremely badly written.

Changing the engine is not hard, but that doesn't mean it will work
exactly as expected.

There are many operational aspects to consider and changing a major
component at the last minute isn't good practice, whether that be
Postgres, sqlite or any other component.

Whatever you plan to use, please use it from the start. If you can.

If there are blockers to doing that for Postgres, please mention it to
me, other community members or on the Postgres lists, so we can help.

--
 Simon Riggs   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: new to Django and building web applications. Advice with postgresql

2013-05-21 Thread Simon Riggs
On 21 May 2013 13:04, Tom Evans  wrote:
> On Sun, May 19, 2013 at 11:51 PM, Scott Anderson
>  wrote:
>> On Sunday, May 19, 2013 11:18:07 AM UTC-4, WongoBongo wrote:
>>>
>>> You don't have to become an expert with postgres to use Django. You can do
>>> most of the db development using SQLite and hold off on postgres until you
>>> are ready to deploy.
>>
>>
>>
>> I highly recommend *against* waiting for PostgreSQL until deployment. There
>> are significant differences between SQLite, PostgreSQL, and MySQL. If you
>> wait until deployment to test on your production database you will find
>> yourself fixing and changing things at the last minute. Start testing on
>> your production deployment database as soon as possible.
>
> The purpose of using an ORM is to make your application database
> agnostic.

ORM stands for Object Relational Mapper. My thinking is that if its
role was solely to make applications database agnostic it would be
called something like Common Database Interface, or Database Agnostic
Layer. Such things do exist, yet so do ORMs. ISTM that ORMs help you
write good applications, not just make things agnostic.

> You should not find that changing DB engine is overly
> taxing.

Hmm, well. A YMMV moment if ever there was one.

> The point is, installing and learning the ins and outs of an RDBMS is
> not necessary to using Django.

Often, yes. But mostly, one needs to consider details about the whole
stack in making things work well.

There are lots of good reasons for careful selection of each part of
your stack. Choosing Django was no doubt an informed decision and one
made with a view to the many good things this gives you. Other
products in your stack benefit from similar careful and informed
decision making.

Otherwise we'd all be using microCOBOL on Netware.

> If you think you are stuck trying to
> install or understand postgres, just ignore it and use sqlite. You can
> always change at a later date.

Changing a major architectural component in your stack is not a
trivial thing. Major changes affect the quality of your deliverables.

The most important thing is that a database is a shared resource. If
you write all your programs assuming you'll be the only user then it
likely won't work very well in production.

--
 Simon Riggs   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: cannot connect to postgresql database

2011-11-23 Thread Simon Riggs
On Wed, Nov 23, 2011 at 1:42 PM, TANYA  wrote:

> hello, i am new to python but want to learn a framework like django so
> i installed it on ubuntu but cannot connect to the postgresql
> databasei done know if this is postgresql problem or ubuntu
> problem or django? where should i ask for help to connect django to
> postgresql?   i follow the tutorial on djangobook.com

We need to know more before anybody can help you, no matter where the
problem lies.

-- 
 Simon Riggs   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

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



Re: Multiple database Router

2011-10-26 Thread Simon Riggs
On Wed, Oct 26, 2011 at 4:19 PM, Tom Evans  wrote:

> Sure, all cars run on top of tarmac,
> but you are unlikely to find a tarmac specialist on a car forum, you
> are better off asking in a more appropriate place.

Happy to bite on that one and am chuckling away at that.

Databases are the engines, and yes, you do find engine specialists in
car forums because cars are the raison d'etre. If Django was a badly
designed car, you wouldn't find such people, that's true.

I'm sure the Red Bull team have similar discussions about whose piece
of the car is most important.

-- 
 Simon Riggs   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

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



Re: Newbee question about PostgreSQL

2011-10-17 Thread Simon Riggs
On Mon, Oct 17, 2011 at 11:58 AM, kenneth gonsalves
 wrote:
> On Mon, 2011-10-17 at 03:00 -0700, Nico wrote:
>> So I tried the command line:
>>    psql myproject george -W
>> This prompted my for the password of george and then returned an
>> error:
>>    psql: FATAL:  Ident authentication failed for user "george"
>
> find pg_hba.conf and change 'ident' to 'password' on the lines at the
> end of the file

Changing the rules in that way would break all existing connections.

You should always use md5 rather than password, since the latter
doesn't encrypt the password.

-- 
 Simon Riggs   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

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



Re: Newbee question about PostgreSQL

2011-10-17 Thread Simon Riggs
On Mon, Oct 17, 2011 at 11:00 AM, Nico  wrote:
> Hi, I am new to Django AND PostgreSQL. I want to setup a PostgreSQL
> backend.
>
> I have created a database
>    createdb myproject
> Then, as superuser in psql:
>    CREATE USER george WITH PASSWORD 'password';
>    GRANT ALL PRIVILEGES ON DATABASE money TO george;
> Then I added this info in settings.py
>
> But, Django gives me an exception:
>   Ident authentication failed for user "george"
>
> So I tried the command line:
>   psql myproject george -W
> This prompted my for the password of george and then returned an
> error:
>   psql: FATAL:  Ident authentication failed for user "george"
>
> For now I have entered my superuser name in settings.py, so I could
> syncdb. The application works. But, of course I need to get this
> working with the user 'george' (fake name for this example) too, so I
> can use that in production environment.
>
> What am I doing wrong?

You need to set your pg_hba.conf settings to allow the user to connect.

The default config on Debian/Ubuntu is to allow you to connect to
Postgres as the same username as the OS user.

This can be modified to allow whatever authentication rule you wish,
per the manual.
http://developer.postgresql.org/pgdocs/postgres/client-authentication.html
or other docs depending upon your db version.

-- 
 Simon Riggs   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

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



Re: Trouble expressing a query in the ORM

2011-09-09 Thread Simon Riggs
On Fri, Sep 9, 2011 at 4:33 PM, Christophe Pettus  wrote:
>
> On Sep 9, 2011, at 6:28 AM, Pewpewarrows wrote:
>
>> prop_dates = 
>> Target.objects.annotate(latest_property=Max('property__export_date')).values_list('latest_property',
>>  flat=True)
>> properties = Property.objects.filter(export_date__in=prop_dates)
>
> Note that if prop_dates has more than 10-15 entries, it's going to perform 
> badly (at least on PostgreSQL, and almost certainly on MySQL too).  I think 
> this particular situation is definitely a .raw() opportunity.

Not sure I understand the limitation to 10-15 entries. Please explain?
Or EXPLAIN?

-- 
 Simon Riggs   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

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



Re: Could not connect postgresql database

2011-08-23 Thread Simon Riggs
On Tue, Aug 23, 2011 at 2:05 PM, SSozuer  wrote:

>        Is the server running locally and accepting
>        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.
> 5432"?

Try connecting on the local system. I would guess you can't. It looks
like you have a problem with the socket directory. Permissions?

> Here is my pg_hba.conf file  settings:

That looks correct.

-- 
 Simon Riggs   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

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



Re: How to configure pgAdminIII

2011-07-15 Thread Simon Riggs
On Fri, Jul 15, 2011 at 4:22 PM, How to configure pgAdminIII
 wrote:

> I recently installed Django, but yet to know how to configure the
> pgAdminIII probably which supports DB for Django apps.
> http://postimage.org/image/13ynpagx0/
>
> This the link which shows I'm stuck with. Can anyone guide me what I
> should do with the form. And anyone tell me how to use it or Works
> with Django if it is postgresql which I was looking for.

That's standard PostgreSQL connection info. The defaults are all
filled in for you, so you just need to give the Server a name to
differentiate it easily in pgAdmin and then supply user/password
details for the database. Whoever installed the database server should
know that.

-- 
 Simon Riggs   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

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



Re: Postgresql transaction error

2011-03-22 Thread Simon Riggs
On Tue, Mar 22, 2011 at 5:03 PM, cootetom  wrote:

> Hi, I've been trying to use Postgresql because I'm thinking of using
> that instead of MySQL due to it's ability to role back transactions
> making it easier to use South. However I've hit a wall with it and
> can't seem to fix it.
>
> I'm using the psycopg2 python library and have tried postgresql 8 and
> now 9.
>
> The error, in brief, is:
>
> "
> Template error
> In template c:\python26\lib\site-packages\django\contrib\admin
> \templates\admin\base.html, error at line 58
> Caught DatabaseError while rendering: current transaction is aborted,
> commands ignored until end of transaction block
> "
>
> By searching Google for this error I have found loads of discussion on
> it but nothing that I have been able to apply in order to fix my
> scenario. I'm getting this error when visiting the Django admin site
> which is probably adding to my confusion because it's code that I'm
> not able to debug.
>
> Has anyone else got any information on this error, or better, a
> solution?

If your transaction throws an error then you must explicitly rollback
the transaction before you continue.

This is a requirement of the SQL standard, not just a PostgreSQL
issue. I can see it would be fairly hard to Google an answer for.

I would guess you started a transaction and then didn't check for
success on an earlier database action before continuing to issue
commands.

This is all normal and good.

-- 
 Simon Riggs   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

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



Re: Database systems

2010-07-16 Thread Simon Riggs
On Fri, 2010-07-16 at 20:33 +0530, Venkatraman S wrote:

> I thought South was DB agnostic.

It is, but databases provide different feature sets. If databases were
all the same there would not be so many to choose from.

-- 
 Simon Riggs   www.2ndQuadrant.com
 PostgreSQL Development, 24x7 Support, Training and Services

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.



Django, Caching and PostgreSQL replication

2010-06-10 Thread Simon Riggs

fyi, PostgreSQL CHAR(10) conference has detailed coverage of
* Django and PostgreSQL replication
* PostgreSQL and memcache
* Latest PostgreSQL 9.0 replication features
* Slony and pgpool updates
* other technologies

CHAR(10) is being held in Oxford, UK on July 2-3.

You can register and/or pay online at
http://www.char10.org/

Please register in next two weeks to avoid late booking fees.

See you there!

-- 
 Simon Riggs   www.2ndQuadrant.com
 PostgreSQL Development, 24x7 Support, Training and Services

-- 
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 at 
http://groups.google.com/group/django-users?hl=en.