Showing posts with label Postgres. Show all posts
Showing posts with label Postgres. Show all posts

Friday, April 19, 2019

Running Odoo and Postgres in separate container




Odoo:

version: '2'

services:
  app:
    image: skyguyver/odoo9_latest
    container_name: develop
    ports:
      - "3033:8069"
    volumes:
      - develop-data:/var/lib/odoo
      - ./addons:/mnt/extra-addons
    environment:
      - PYTHONUNBUFFERED=1
      - HOST=172.18.0.1
      - PORT=3032
      - USER=odoo
      - PASSWORD=odoo
    #command: openerp-server -d develop -u all

volumes:
  develop-data:


Postgres:

version: '2'

services:
  db:
    image: postgres:9.6
    ports:
      - "3032:5432"
    environment:
      - POSTGRES_USER=odoo
      - POSTGRES_PASSWORD=odoo
      - PGDATA=/var/lib/postgresql/data/pgdata
    volumes:
      - dbdata:/var/lib/postgresql/data/pgdata

volumes:
  dbdata:

Sunday, February 17, 2019

Error starting userland proxy: listen tcp 0.0.0.0:5432: bind: address already in use

This issue happens when I installed Postgres in my vagrant (vm) and then I after a while I removed it. But the service is still running in the system causing the default 5432 port is not available to be used.





first I run this command

sudo apt-get --purge remove postgresql


but still, it didn't totally remove. so I have to run this command to list all running postgres

dpkg -l | grep postgres



then, I run again this command

sudo apt-get --purge remove postgresql postgresql-doc postgresql-common






Eureka!

Thanks for this reference
https://askubuntu.com/questions/32730/how-to-remove-postgres-from-my-installation

Wednesday, November 28, 2018

Postgres SQL


To get the 12HH with AM/PM

select to_char(create_date at time zone 'utc', 'HH12:MI:SS AM') as "createdate", proc_type, state, * from vb_proc_queue where proc_type='Email1SubsqSignUpNotify' order by create_date desc

04:18:19 PM

Sunday, August 5, 2018

Postgres backup and restore

Backup commands
- pg_dump db_name > db_backup.sql
- pg_dumpall > cluster_backup.sql

Restore commands
- psql db_name < db_backup.sql
- psql -f cluster_backup.sql postgres


Using compression
- pg_dump db_name | gzip > db_backup.gz
- pg_dumpall | gzip > cluster_backup.gz

Restore
- gunzip -c db_backup.gz | psql db_name
- gunzip -c cluster_backup.gz | psql postgres




reference:
https://www.rubytreesoftware.com/resources/basic-postgresql-backup-and-restore/

Tuesday, July 24, 2018

How to install postgresql into ubuntu

Installation

sudo apt-get update
sudo apt-get install postgresql postgresql-contrib



Backup
pg_dump my_postgres_db > my_postgres_db.sql

Restore
plsql my_postgres_db < my_postgres_db.sql




Saturday, December 23, 2017

How to list specific column name in the table

SELECT * FROM information_schema.columns WHERE table_catalog = 'myevo' AND table_name  = 'purchase_order' and column_name = 'batch_id'


sorted

SELECT * FROM information_schema.columns WHERE table_catalog = 'vbroker20-beta1' AND table_name  = 'vb_trade_tran' order by column_name

Tuesday, September 5, 2017

Morning headache with Postgresql

While I'm doing python exercise. Suddenly, my database connection was down for no reason. It takes me 2 hours to fix the issue and I almost gave up. Damn it! actually, I didn't say that until now. haha

But I learn new stuff today especially postgres commands, like:

To check the database server status

/etc/init.d/postgresql status


As usual, my friend google help me find out the solution and took me a while to find it. Here's the link https://askubuntu.com/questions/50621/cannot-connect-to-postgresql-on-port-5432




First purge the old postgres install.

sudo apt-get remove --purge postgresql-9.3

Now simply reinstall

sudo apt-get install postgresql-9.3




Now, when I run my odoo. My username "devlynard" was not found it is because I reinstall the postgres. So, I just add it back. 




Eureka!





Thursday, March 30, 2017

Install Odoo 9 and Postgresql 9.3 inside docker container

Currently I'm working on a Odoo application where we installed our development environment in the Ubuntu/VMware. Apparently, I also like to know how to install the same setup using docker container and I tell you its not easy but luckily after few trial, here's my command that works perfectly.


1. Install postgres 9.3 with username = admin and password = admin. Port is default 5432 and the name of the container is postgres9.3, its makes sense. I'm not sure what is the --restart=always attribute but we can just leave that as is it.

docker run -d -e POSTGRES_USER=admin -e POSTGRES_PASSWORD=admin --name postgres9.3 -p 5432:5432 --restart=always postgres:9.3


2. Install Odoo 9 with default port 8069. The container name is odoo9 and its link with the postgres installed as above. That's it, very simple but it took me a while to figure it out. I'm still not an expert devops.

docker run -p 8069:8069 --name odoo9 --link postgres9.3:db -t odoo:9


mount custom addons
docker run -v /dev_path/svn/repo2/trunk:/mnt/extra-addons -p 8069:8069 --name vbroker --link postgres9.3:db -t ls/odoo9



Updated:
Everything works fine on the above setup however when I launch my code , it shows warning that need to install pika module. So I decided to get the Dockerfile from official odoo 9 installation from github. https://hub.docker.com/_/odoo/



build again using below command
$docker build -t <name> .

Eureka!

free online comma separating tool

https://delim.co/#