Monday, November 19, 2012

How do I enable remote access to my Postgre database?

The actual file contents you used:





How do I enable remote access to my Postgre database?

http://kb.mediatemple.net/questions/1237/How+do+I+enable+remote+access+to+my+PostgreSQL+server%3F#dv


External PostgreSQL connections

1. To be able to reach the server remotely you have to add the following line into the file:/var/lib/pgsql/data/postgresql.conf:
listen_addresses = '*'
2. PostgreSQL, by default, refuses all connections it receives from any remote address. You have to relax these rules by adding this line to /var/lib/pgsql/data/pg_hba.conf:
host all all  0.0.0.0/0 md5
This is an access control rule that lets anyone login from any address if a valid password is provided (the md5 keyword). You can use your network/mask instead of 0.0.0.0/0 to only allow access from certain IP addresses.
3. When you have applied these modifications to your configuration files, you will need to restart the PostgreSQL server.
/etc/init.d/postgresql start

http://www.cyberciti.biz/tips/postgres-allow-remote-access-tcp-connection.html

Edit the file:
$ vi /var/lib/pgsql/data/pg_hba.conf
OR
$ vi /etc/postgresql/8.2/main/pg_hba.conf
Append the following configuration lines to give access to 10.10.29.0/24 network:
host all all 10.10.29.0/24 trust
Save and close the file. Make sure you replace 10.10.29.0/24 with actual network IP address range of the clients system in your own network.




installing postgresql on debian 6

http://library.linode.com/databases/postgresql/debian-6-squeeze

postgres allow remote connection
http://www.ndchost.com/wiki/postgres/remote-access
http://blog.akendo.eu/enable-remote-access-postgresql/

sqlalchemy postgres connection string
http://docs.sqlalchemy.org/en/rel_0_7/core/engines.html

from sqlalchemy import create_engine
engine = create_engine('postgresql://scott:tiger@localhost:5432/mydatabase')
The above engine creates a Dialect object tailored towards PostgreSQL, as well as a Pool object which will establish a DBAPI connection at localhost:5432 when a connection request is first received. Note that the Engine and its underlying Pool do not establish the first actual DBAPI connection until theEngine.connect() method is called, or an operation which is dependent on this method such asEngine.execute() is invoked. In this way, Engine and Pool can be said to have a lazy initializationbehavior.


http://docs.sqlalchemy.org/en/rel_0_7/dialects/mysql.html


Unicode

MySQLdb will accommodate Python unicode objects if the use_unicode=1 parameter, or the charsetparameter, is passed as a connection argument.
Without this setting, many MySQL server installations default to a latin1 encoding for client connections, which has the effect of all data being converted into latin1, even if you have utf8 or another character set configured on your tables and columns. With versions 4.1 and higher, you can change the connection character set either through server configuration or by including the charsetparameter. The charset parameter as received by MySQL-Python also has the side-effect of enablinguse_unicode=1:
# set client encoding to utf8; all strings come back as unicode
create_engine('mysql+mysqldb:///mydb?charset=utf8')
Manually configuring use_unicode=0 will cause MySQL-python to return encoded strings:
# set client encoding to utf8; all strings come back as utf8 str
create_engine('mysql+mysqldb:///mydb?charset=utf8&use_unicode=0')

Known Issues

MySQL-python version 1.2.2 has a serious memory leak related to unicode conversion, a feature which is disabled via use_unicode=0. It is strongly advised to use the latest version of MySQL-Python.



http://www.postgresql.org/docs/8.1/static/sql-grant.html


The possible privileges are:
SELECT
Allows SELECT from any column of the specified table, view, or sequence. Also allows the use of COPY TO. This privilege is also needed to reference existing column values in UPDATE or DELETE. For sequences, this privilege also allows the use of the currval function.
INSERT
Allows INSERT of a new row into the specified table. Also allows COPY FROM.
UPDATE
Allows UPDATE of any column of the specified table. (In practice, any nontrivial UPDATE command will require SELECT privilege as well, since it must reference table columns to determine which rows to update, and/or to compute new values for columns.) SELECT ... FOR UPDATE and SELECT ... FOR SHARE also require this privilege, in addition to the SELECT privilege. For sequences, this privilege allows the use of the nextval andsetval functions.
DELETE
Allows DELETE of a row from the specified table. (In practice, any nontrivial DELETE command will require SELECT privilege as well, since it must reference table columns to determine which rows to delete.)
RULE
Allows the creation of a rule on the table/view. (See the CREATE RULE statement.)
REFERENCES
To create a foreign key constraint, it is necessary to have this privilege on both the referencing and referenced tables.










No comments:

Post a Comment