You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-6Lines changed: 8 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ At current state it only works with Python 2.*
17
17
18
18
> Node: by default testgres runs `initdb`, `pg_ctl`, `psql` commands from the `$PATH`. To specify custom postgres installation set environment variable `$PG_CONFIG` and point it to pg_config executable: `export PG_CONFIG=/path/to/pg_config`
19
19
20
-
Here is an example of how you can use `testgres`
20
+
Here is an example of how you can use `testgres`.
21
21
22
22
```python
23
23
from testgres import get_new_node
@@ -39,13 +39,13 @@ Let's walk through the code. First you create new node:
39
39
node = get_new_node('master')
40
40
```
41
41
42
-
`master` here is a node's name, not the database's name. The name matters if you're testing replication. Function get_new_node() only creates directory structure in `/tmp` for cluster. Next line:
42
+
`master` here is a node's name, not the database's name. The name matters if you're testing replication. Function `get_new_node()` only creates directory structure in `/tmp` for cluster. Next line:
43
43
44
44
```python
45
45
node.init()
46
46
```
47
47
48
-
initializes claster. On low level it runs `initdb` command and adds some basic configuration to `postgresql.conf` and `pg_hba.conf` files. Function `init()` accepts optional parameter `allows_streaming` which configures cluster for streaming replication (default is `False`).
48
+
initializes cluster. On low level it runs `initdb` command and adds some basic configuration to `postgresql.conf` and `pg_hba.conf` files. Function `init()` accepts optional parameter `allows_streaming` which configures cluster for streaming replication (default is `False`).
49
49
Now we are ready to start:
50
50
51
51
```python
@@ -54,12 +54,14 @@ node.start()
54
54
55
55
After this you are able to run queries over the cluster. There is three functions to do that:
56
56
57
-
* node.psql(database, query) - runs query via `psql` command and returns tuple (error code, stdout, stderr)
58
-
* node.safe_psql(database, query) - the same as `psql()` except that it returns only `stdout`. If error occures during the execution then it will throw an exception;
59
-
* node.execute(database, query) - connects with postgresql server using `psycopg2` or `pg8000` library (depends on which is installed in your system) and returns two-dimensional array with data.
57
+
*`node.psql(database, query)` - runs query via `psql` command and returns tuple (error code, stdout, stderr)
58
+
*`node.safe_psql(database, query)` - the same as `psql()` except that it returns only `stdout`. If error occures during the execution then it will throw an exception;
59
+
*`node.execute(database, query)` - connects with postgresql server using `psycopg2` or `pg8000` library (depends on which is installed in your system) and returns two-dimensional array with data.
60
60
61
61
To stop server run:
62
62
63
63
```python
64
64
node.stop()
65
65
```
66
+
67
+
Please see `testgres/tests` directory for replication configuration example.
0 commit comments