I'm trying to set-up a django system comprising a separate web
server, static server and database server.
Where does Psychopg live: on the web or database server?
And how would I go about configuring the two?
Cheers
Mark
Should get more sleep
In direct answer to your question, psycopg provides a database driver
for Postgres and is meant to be used by clients of the database - in
your case this would be the web server. As far as your question about
configuring everything, that leads me to believe that you are fairly
new to either web development or software development in general.
The answer(s) to that question may be beyond the scope of this group.
Not to discourage you, but you may have your work cut out for you.
That said, I think you will find that this and other open source
communities are very friendly and helpful as long as you are willing
to make an effort on your end as well. I would advise reading through
tutorials - both on the Django site as well as the sites for the
requisite technologies (Apache/FastCGI, mod_python, PostgreSQL). In
each case, I would focus on getting that particular piece installed
and configured so that you have some basic familiarity with each piece
before you start working with the stack as a whole. Also, I would
recommend setting up the web+database server all on the same server to
begin with. While distributing your services across multiple servers
is an excellent idea and a requisite for scalability, it also
introduces complexities and configuration/security considerations.
Start simple, verify and get comfortable with the setup, and then take
steps to achieve the setup you desire.
Hope this helps.
-Brian
I've actually got django up a running nicely on a single web/database
server under mod_python and Postgres and have been working with that
for about 6 months. All is fine on that front and now I want to test
the apps scalabilty amongst other things and therefore want to set-up
a 3 server system (like the one in the Djangobook).
There seems to little to no documentation on how to set-up the
configuration files of setup.cfg in Psycopg or any of the other apps
for that matter. I asked such a broad question in case someone might
be able to point me in the right direction. I guess I want to know
how to make the Apache server and the Postgres server talk to each
other over a network connection and not locally on the same machine.
Thanks
Mark
When installing Psychopg2, if the Database server was on the same
machine as the Web server, I would normally update the setup.cfg
prior to running "python setup.py build", with the following:
pg_config=/usr/local/pgsql/bin/pg_config
library_dirs=/usr/local/pgsql/lib
However, as I want to separate the Web server and the Database
server, and the above file and directory are on another machine (say
192.168.344.222), what should I enter in these fields?
Would mounting the "pgsql" directory from the Web server with NFS be
the recommended solution? Or will a lot of customisation be necessary?
I notice that quite a few sites are running set-ups that separate the
servers according to their function (web, static and database), so
this can't be a rare set-up.
Thanks in advance
Mark
I don't really understand what you're trying to do with setup.cfg (what
package is this setup file for?), but to answer your original question,
the psycopg module lives on the database client side -- so on the web
server in this case. It is loaded and used by the webserver code to act
as a client to talk to a remote database server. Basically psycopg2 is
the python equivalent of the psql program.
Regards,
Malcolm
running buildcd install/psycopg2-2.0.5.1
running build_pyall/psycopg2-2.0.5.1# ls
running build_ext INSTALL MANIFEST psycopg setup.cfg ZPsycopgDA
Warning: /bin/sh: line 1: pg_config: command not foundtup.py
building 'psycopg2._psycopg' extension scripts tests
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -DPY_MAJOR_VERSION=2 -DPY_MINOR_VERSION=5 -DHAVE_PYBOOL=1 -DHAVE_DECIMAL=1 -DHAVE_PYDATETIME=1 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.0.5.1 (dec dt ext pq3)" -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_DISPLAY_SIZE=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -DHAVE_PQPROTOCOL3=1 -I/usr/local/include/python2.5 -I. -c psycopg/psycopgmodule.c -o build/temp.linux-i686-2.5/psycopg/psycopgmodule.o
In file included from psycopg/psycopgmodule.c:28:
./psycopg/connection.h:26:22: error: libpq-fe.h: No such file or directory
In file included from psycopg/psycopgmodule.c:28:
./psycopg/connection.h:55: error: expected specifier-qualifier-list before 'PGconn'
In file included from psycopg/psycopgmodule.c:29:
./psycopg/cursor.h:55: error: expected specifier-qualifier-list before 'PGresult'
psycopg/psycopgmodule.c: In function '_psyco_connect_fill_exc':
psycopg/psycopgmodule.c:103: error: 'connectionObject' has no member named 'exc_Error'
psycopg/psycopgmodule.c:105: error: 'connectionObject' has no member named 'exc_Warning'
psycopg/psycopgmodule.c:107: error: 'connectionObject' has no member named 'exc_InterfaceError'
psycopg/psycopgmodule.c:109: error: 'connectionObject' has no member named 'exc_DatabaseError'
psycopg/psycopgmodule.c:111: error: 'connectionObject' has no member named 'exc_InternalError'
psycopg/psycopgmodule.c:113: error: 'connectionObject' has no member named 'exc_ProgrammingError'
psycopg/psycopgmodule.c:115: error: 'connectionObject' has no member named 'exc_IntegrityError'
psycopg/psycopgmodule.c:117: error: 'connectionObject' has no member named 'exc_DataError'
psycopg/psycopgmodule.c:119: error: 'connectionObject' has no member named 'exc_NotSupportedError'
psycopg/psycopgmodule.c:121: error: 'connectionObject' has no member named 'exc_OperationalError'
error: command 'gcc' failed with exit status 1
I'm asking what do I place into the pg_config and library_dirs in order for the installation to work on the client web server? Or what do I in general to make it work?
I mentioned in my previous email, that pg_config=/usr/local/pgsql/bin/pg_config and library_dirs=/usr/local/pgsql/lib on the database, but how do I reference this in the installation of Psychpg on the client webserver?
Realised you need to install libpq-fe.h before you can install psycopg.
Which under Debian is simply installed with: apt-get install libpq-dev
Thanks
mark
I don't know what you mean by "place into". Make sure you read the
INSTALL and README files carefully that came with your psycopg
tarball. (PS I'd recommend using version 2 of psycopg just in case
you aren't already). This is directly from setup.cfg in a recent
version of pyscopg:
# "pg_config" is the preferred method to locate PostgreSQL headers and
# libraries needed to build psycopg2. If pg_config is not in the path
or
# is installed under a different name uncomment the following option
and
# set it to the pg_config full path.
#pg_config=
pg_config is a command that comes with Postgres and provides
configuration parameters relating to your installation of Postgres.
You can check if it is installed by entering "pg_config" on the
command line. If you get a listing of key-value pairs relating to the
installation of Postgres, then it is installed and on your system
path, therefore the psycopg build should be able to locate and use
it. If you get "command not found", then it is either not installed
or not on the system path. If thats the case (and it sounds like it
is), then you have two options:
1) figure out how to get pg_config installed or if it is and is just
not on the path, add the location of the command to your system path.
2) follow the optional instructions in setup.cfg:
# If "pg_config" is not available, "include_dirs" can be used to
locate
# postgresql headers and libraries. Some extra checks on sys.platform
will
# still be done in setup.py.
# The next line is the default as used on psycopg author Debian
laptop:
#include_dirs=/usr/include/postgresql:/usr/include/postgresql/server
What this means is you need to make the Postgres headers and libs
available so the psycopg build can find the appropriate headers and
link to the Postgres client libs.
Now I'm not sure what OS you're on, but most of the modern linux
distros have some sort of package management utilities that will grab
these packages, install, and configure them in a manner that is
consistent with conventions on the particular OS of your choice. For
example I use Debian/Ubuntu and the process of installing these would
be (this is not verbatim, just illustrating)
--install postgres
# apt-get install postgresql-8.2
--install postgres headers and libs
# apt-get install postgresql-8.2-dev
--install psycopg2
# apt-get python-psycopg2
Again, I don't remember the exact package names. Hope this helps. If
you're having trouble configuring Postgres in a client/server setup, I
would search and direct your questions to postgres mailing lists and
forums and look for tips relating specifically to your OS.
-Brian
On Apr 17, 9:38 pm, "mjare...@bigpond.net.au"