I installed a postgres cluster using pgpool on docker containers, link . I can connect to pgpool and make insertions and other normal sql commands.
psql monkey_db -h localhost -U monkey_user -p 5430
But when I try to connect the database using python psycopg2, I make inserts and apparently they are saved, but I leave the connection and look at psql and see that nothing has been saved. On returning to python I see that nothing has been saved.
(docker) root@prisvo-asus:~# psql monkey_db -h localhost -U monkey_user -p 5430
monkey_db=# create table teste(num bigint);
CREATE TABLE
monkey_db=# insert into teste values(123);
INSERT 0 1
monkey_db=# select * from teste;
num
----
123
(1 row)
monkey_db=# \q
(docker) root@prisvo-asus:~# ipython
In [1]: import psycopg2
In [2]: con = psycopg2.connect(dbname='monkey_db',user='monkey_user',password='monkey_pass', host='localhost',port='5430')
In [3]: cur = con.cursor()
In [4]: query = 'select * from teste;'
In [5]: cur.execute(query);
In [6]: rows = cur.fetchall()
In [7]: for row in rows:
..: print(row[0])
123
In [8]: query = 'insert into teste values(1111)';
In [9]: cur.execute(query);
In [10]: query = 'select * from teste;'
In [11]: cur.execute(query);
In [12]: rows = cur.fetchall()
In [13]: for row in rows:
..: print(row[0])
123
1111
In [14]: exit()
(docker) root@prisvo-asus:~# psql monkey_db -h localhost -U monkey_user -p 5430
monkey_db=# select * from teste;
num
----
123
(1 row)
monkey_db=# \q
(docker) root@prisvo-asus:~# ipython
In [1]: import psycopg2
In [2]: con = psycopg2.connect(dbname='monkey_db',user='monkey_user',password='monkey_pass', host='localhost',port='5430')
In [3]: cur = con.cursor()
In [4]: query = 'select * from teste;'
In [5]: cur.execute(query);
In [6]: rows = cur.fetchall()
In [7]: for row in rows:
..: print(row[0])
123