Hi,
> I do not see any information on the generally excellent Django website about alternatives to psychopg as a PostGreSQL connector. I have been having some non-Django problems getting psychopg to work so it would be nice if there was another option such as pypgsql.
Wich problems did you have? psycopg rocks :-D
If it was only a licence issue, please see below.
> While researching I did find this page:
http://blog.vrplumber.com/968 so it seems that I am not the only one with this request.
Thank you for the signalation. I've submitted it to Federico (the main
psycopg author) and he reply with a comment on the page.
I've discussed this issue with him some time ago. The reason why
psycopg is GPL'd is only to avoid that non free drivers will be
derived from it. I can guarantee that nobody in initd will pursue no
one for *using* it in non-GPL projects.
We recently rewrote the license of psycopg2 in order to explain that. See:
http://initd.org/tracker/psycopg/file/psycopg2/trunk/LICENSE
This is the intended behavior of the license also for psycopg1, even
if not explicitly stated. Or, if that make you feel better, you can
use psycopg2 with Django with *one* of the two trivial patches
1. using psycopg2 -> psycopg1 compatiblity layer
{{{
Index: django/trunk/django/core/db/backends/postgresql.py
===================================================================
--- django/trunk/django/core/db/backends/postgresql.py (revision 618)
+++ django/trunk/django/core/db/backends/postgresql.py (local copy)
@@ -5,7 +5,7 @@
"""
from django.core.db import base, typecasts
-import psycopg as Database
+import psycopg2.psycopg1 as Database
DatabaseError = Database.DatabaseError
}}}
2. using either psycopg1 or psycopg2 full power, at your choice (untested)
{{{
Index: django/trunk/django/core/db/backends/postgresql.py
===================================================================
--- django/trunk/django/core/db/backends/postgresql.py (revision 618)
+++ django/trunk/django/core/db/backends/postgresql.py (local copy)
@@ -5,7 +5,12 @@
"""
from django.core.db import base, typecasts
-import psycopg as Database
+try:
+ import psycopg2 as Database
+ from psycopg2.extensions import register_type
+except ImportError:
+ import psycopg as Database
+ from psycopg import register_type
DatabaseError = Database.DatabaseError
@@ -115,13 +120,10 @@
# Register these custom typecasts, because Django expects dates/times to be
# in Python's native (standard-library) datetime/time format, whereas psycopg
# use mx.DateTime by default.
-try:
- Database.register_type(Database.new_type((1082,), "DATE",
typecasts.typecast_date))
-except AttributeError:
- raise Exception, "You appear to be using psycopg version 2, which
isn't supported yet, because it's still in beta. Use psycopg version 1
instead:
http://initd.org/projects/psycopg1"
-Database.register_type(Database.new_type((1083,1266), "TIME",
typecasts.typecast_time))
-Database.register_type(Database.new_type((1114,1184), "TIMESTAMP",
typecasts.typecast_timestamp))
-Database.register_type(Database.new_type((16,), "BOOLEAN",
typecasts.typecast_boolean))
+register_type(Database.new_type((1082,), "DATE", typecasts.typecast_date))
+register_type(Database.new_type((1083,1266), "TIME", typecasts.typecast_time))
+register_type(Database.new_type((1114,1184), "TIMESTAMP",
typecasts.typecast_timestamp))
+register_type(Database.new_type((16,), "BOOLEAN", typecasts.typecast_boolean))
OPERATOR_MAPPING = {
'exact': '=',
}}}
HTH, HAND
(c)
--
Carlo C8E Miron, ICQ #26429731
--
Disclaimer:
If I receive a message from you, you are agreeing that:
1. I am by definition, "the intended recipient".
2. All information in the email is mine to do with as I see fit and
make such financial profit, political mileage, or good joke as it
lends itself to. In particular, I may quote it on USENET or the WWW.
3. I may take the contents as representing the views of your company.
4. This overrides any disclaimer or statement of confidentiality that
may be included on your message.