PHP » PYTHON |
login |
register |
about
|
PYTHON pg_connect
is this article helpful?
|
Python replacement for PHP's pg_connect
[
edit
| history
]
import psycopg2 db_connection = psycopg2.connect(host="my host", database="my database", user="myself", password="my rich aunts birthday") db_handle = db_connection.cursor() http://initd.org/psycopg/docs/usage.html pg_connect(PHP 4, PHP 5) pg_connect — Open a PostgreSQL connection Description
resource pg_connect
( string $connection_string
[, int $connect_type
] )
pg_connect() opens a connection to a PostgreSQL database specified by the connection_string . If a second call is made to pg_connect() with the same connection_string as an existing connection, the existing connection will be returned unless you pass PGSQL_CONNECT_FORCE_NEW as connect_type . The old syntax with multiple parameters $conn = pg_connect("host", "port", "options", "tty", "dbname") has been deprecated. Parameters
Return ValuesPostgreSQL connection resource on success, FALSE on failure. Examples
Example #1 Using pg_connect()
<?php
See Also
|
more
Recently updated
more
Most requested
more
Last requests
|