반응형

windows 7 방화벽 port 열기


환경: windows 7 64bit


참고 : http://www.dummies.com/how-to/content/how-to-open-a-port-in-the-windows-7-firewall.html

         PostgreSQL Cookbook, p.29~31




< 가정 >

현재의 windows 7 에 PostgreSQL db 설치 되어있고, 외부에서 postgresql db에 접속하기 위해서는  5432 port 가 열려있어야함.

 --> 대분분은 설정안해도 되지만, 방확벽에 막힌 경우는 아래와 같이 설정해줘야 외부에서 postgresql db 접속가능하다.



< 해결책 > 

1. 방화벽 고급설정 선택




2. 인바운드 규칙 선택후 --> 새 규칙 선택




3.  포트 선택





4. TCP, UDP 중 원하는 것 선택하고, 포트 번호 지정하기

   -- 아래의 경우는 postgresql db 를 설치한 pc에서 TCP 포트 5432 사용하게 설정함.




5. 필요한 연결 허용 선택.




6. 필요에따라 해당 프로필 선택.




7. 적당한 이름 설정하기 




8. 설정을 마친후, 위에서 만든 postgresqlport 이름이 인바운드 규칙에 보이면 성공...




반응형
Posted by 자유프로그램
,
반응형

postgresql 9.4.2 & pgAdmin III 설치하기 

 -- ubuntu 14.04LTS



환경 : ubuntu 14.04LTS 64bit , postgresql 9.4, pgAdmin III 1.20.0 


참고 :  https://help.ubuntu.com/community/PostgreSQL

        http://www.postgresql.org/download/linux/ubuntu/

        http://www.unixmen.com/install-postgresql-9-4-phppgadmin-ubuntu-14-10/

        http://www.postgresql.org/docs/9.2/static/app-psql.html

        http://www.postgresql.org/docs/9.4/static/sql-createdatabase.html


참고서적 : https://www.packtpub.com/big-data-and-business-intelligence/postgresql-cookbook




1. postgresql linux 다운로드 사이트에 나온 설명대로, 셋팅하고 upgrade 한후, 설치하기.



**아래 순서대로 터미널에 명령어 입력후 실행하자.


$ sudo apt-get update


   



$ sudo vim /etc/apt/sources.list.d/pgdg.list

  --> 해당 디렉토리에 pgdg.list 라는 파일을 만들어 다음 내용을 입력후 저장한다.

  --> deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main  


   


$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -




$ sudo apt-get update

    --> 리포지토리 반영하기위해 update 하면, ubuntu에서 postgresql-9.4 를 인식한다.


$ sudo apt-get install postgresql-9.4

  --> postgresql-9.4  설치하기.


$ sudo apt-get install pgadmin3

  --> pdadmin III 설치하기.




2. psql 실행하기


** 설치후 바로 psql 실행해 보면, 사용자 틀리다고 에러 발생한다.

  -- postgresql 은 설치시에 사용자 postgres, 데이터베이스 postgres 로 기본 설정되 있다.


    



** 해결책 2가지


1) postgres user 로서 psql 명령어 실행하기.




2) postgres user 로 변경후, psql 실행하기.



  ---> exit 명령어 치면, 사용자가 다시 parkhh 로 바뀐다.



3. 암호 설정하기.

   -- 참고 : http://www.postgresql.org/docs/9.2/static/app-psql.html



--- 이제부터는 pgAdmin III 에서 postgres 데이터베이스에 연결할수있다.



4. database 만들기 

  -- 2가지 방법 ( pgadmin III 를 이용해서 만들어도 됨.)

  

1) createdb 이용하기 -- superuser 나 해당 권한있는 user 만 가능함.

   -- 참고 : http://www.postgresql.org/docs/9.4/static/app-createdb.html

  

   $ sudo -u postgres createdb demo

    ==> demo 라는 이름의 db 만들기.

  


2) sql 이용하기

  -- 참고  : http://www.postgresql.org/docs/9.4/static/sql-createdatabase.html



5. user 만들기  


1) createuser 이용하기 -- superuser 나 해당 권한있는 user 만 가능함.

  -- 참고 : http://www.postgresql.org/docs/9.4/static/app-createuser.html


   $ sudo -u postgres createuser -D -P newuser

    ==>  -D ; db 생성은 못함,   -P ; password 입력 설정.


  




2) sql 이용하기

  -- 참고 : http://www.postgresql.org/docs/9.4/static/sql-createuser.html




6. user 삭제하기

-- 터미널에서 dropuser 명령 사용

$ sudo -u postgres dropuser newuser

==> newuser 라는 이름의 user 삭제하기.


7. 외부 접속 허용을 위한 설정하기

1) pg_hba.conf 파일 설정하기

$ sudo vim /etc/postgresql/9.4/main/pg_hba.conf

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host    all             all             192.168.1.0/24          md5

==> An IP address range is specified using standard numeric notation for the range's starting address, then a slash (/) and a CIDR mask length. 
The mask length indicates the number of high-order bits of the client IP address that must match. 
Bits to the right of this should be zero in the given IP address. 
There must not be any white space between the IP address, the /, and the CIDR mask length.

==> IP-address/mask-length notation
  ; For example, 255.0.0.0 represents an IPv4 CIDR mask length of 8, and 255.255.255.255 represents a CIDR mask length of 32.



2) postgresql.conf 파일 설정하기

$ sudo vim /etc/postgresql/9.4/main/postgresql.conf

listen_addresses = '*'
port = 5432

# ssl = on  # ssl setting 


3) 위의 설정 변경후에는 재시작 해야함.


$ sudo service postgresql restart



** 참고 : 필요하면 TCP port 5432 열어줘야함.



8. SSL 설정하기


  참고 - http://www.postgresql.org/docs/9.4/static/ssl-tcp.html

        - PostgreSQL Cookbook chapter 2. 

        - https://support.ca.com/cadocs/0/CA%20Application%20Performance%20Management%209%206-KOR/Bookshelf_Files/HTML/APM--Installation%20and%20Upgrade%20Guide/index.htm?toc.htm?2238069.html










반응형
Posted by 자유프로그램
,
반응형

postgresql 9.4.2 & pgAdmin III 설치하기  -- windows


환경 : windows 8 64bit, postgresql 9.4.2 64bit 


참고:

   - postgresql 9.4.2 다운로드 사이트 : http://www.enterprisedb.com/products-services-training/pgdownload#windows




1. windows 용 postgresql 9.4.2 installer 다운 받기.

  

   -- postgresql 9.4.2 다운로드 사이트 : http://www.enterprisedb.com/products-services-training/pgdownload#windows



2. 설치하기 

  -- 다운받은 postgresql-9.4.2-1-windows-x64.exe 을 실행하여 설치한다.







    -- 설치 폴더는 원하는 곳으로...설정.














     -- locale 은 한국으로 함.






     -- 설치중....



      -- 설치 완료후, Stack Builder 실행할지 물어봄. 




    ** 추가로 plugin 프로그램 필요없으면, Stack Builder 는 실행할 필요없다. (체크해제하고 Finish 하면 설치 끝.)




3. pgAdmin III 실행하기  --- 시작메뉴에서 pgAdmin III 선택하여 실행한다.





1) 로컬에서 실행후 화면




2) postgresql db 연결하기.






 --> 설치 중에 생성한 database superuser(postgres) password 를 입력한다.



3) postgresql db 연결완료후 화면.




4) pgAdmin III 에서 database 만들기.




5) 새 Table 만들기 





4. psql 실행하기



    


  -- postgresql 설치후 시작메뉴에서 처음 psql 실행시에는 밑줄친 부분을 입력해야 한다...

     ; password 는 설치시에 설정한 password 입력하면 된다. 

      -  위의  pgAdmin III 화면에서도  보이듯이, 설치시에 postgres 라는 database 는 형성되어있고, owner 또한 postgres !!!




5. 외부 접속 허용을 위한 설정하기
   -- 설치 직후에는 localhost 에서만 postgresql 접근가능하므로, 다른 네트워크에서 접속 가능하게 설정 해줘야한다.

1) pg_hba.conf 파일 설정하기
  -- 192.168.1 로 시작하는 모든 내부망의 연결을 허가하기 위해서는 192.168.1.0/24 을 추가한다. 
  -- 여기서 /24 는 CIDR 표시로, 상위 24bit 가 1 이라는 의미, /32 는  상위 32bit 가 1 이다.
     즉, /24 는  11111111.11111111.11111111.00000000 을 의미 (즉, 255.255.255.0) 한다.
     이는 상위 24bit 가 일치하는 모든 네트워크 접속을 허락한다는 의미이다.
     192.168.1.0 ~ 192.168.1.255 까지 모든 접속허가...

     host    all             all             192.168.1.0/24            md5
     를 # IPv4 local connections: 항목 아래에 추가해 주면 끝.

    

2) postgresql.conf 파일 설정하기


listen_addresses = '*'
port = 5432


3) 방화벽 TCP port 5432 열어주기.

  -- http://freeprog.tistory.com/97  참고하여 설정하면 됨.



6. SSL 설정하기


windows 7 에 설치된 postgresql 9.4 에 SSL 설정하기 ( http://freeprog.tistory.com/120 ) 에 정리함.


  참고 - http://www.postgresql.org/docs/9.4/static/ssl-tcp.html

        - PostgreSQL Cookbook chapter 2. 

        - https://support.ca.com/cadocs/0/CA%20Application%20Performance%20Management%209%206-KOR/Bookshelf_Files/HTML/APM--Installation%20and%20Upgrade%20Guide/index.htm?toc.htm?2238069.html




반응형
Posted by 자유프로그램
,
반응형

SQLAlchemy 설치 & tutorial 


설치환경 : windows 7 64bit , SQLAlchemy 1.0.4


참고 : http://docs.sqlalchemy.org/en/latest/orm/tutorial.html

       http://docs.sqlalchemy.org/en/rel_1_0/core/engines.html

       http://docs.sqlalchemy.org/en/latest/core/connections.html



1. 설치하기

   --  http://docs.sqlalchemy.org/en/rel_1_0/intro.html#installation 에 나온대로 

        pip install SQLAlchemy  

        명령으로 command 창에서 실행하였으나, C Extension 컴파일 못함. 

        --> import sqlalchemy 

            명령어 치면, 잘되지만.. 찝찝해서  다시  

             pip uninstall SQLAlchemy  하고, 


        http://www.lfd.uci.edu/~gohlke/pythonlibs/#sqlalchemy 사이트에서 다운 받아 pip 로 재설치함.






2. tutorial 따라하기.

  -- http://docs.sqlalchemy.org/en/latest/orm/tutorial.html


  ** Session 에 관한 글 : http://docs.sqlalchemy.org/en/latest/orm/session_basics.html#session-faq-whentocreate




  ** 올바른 Session 사용법

      http://docs.sqlalchemy.org/en/latest/orm/session_basics.html#when-do-i-construct-a-session-when-do-i-commit-it-and-when-do-i-close-it



  ** Is the session thread-safe? NO!!!!

     - http://docs.sqlalchemy.org/en/latest/orm/session_basics.html#is-the-session-thread-safe


    Making sure the Session is only used in a single concurrent thread at a time is called a “share nothing” approach to concurrency.



3. database 접속하기

  -- 참고 : http://docs.sqlalchemy.org/en/latest/core/connections.html#basic-usage


1) 기존의 postgresql database 연결하기




2) 기존의 sqlite database 연결하기



4. 


반응형
Posted by 자유프로그램
,
반응형

wx.ComboBox -- item 추가하기


참고 : http://stackoverflow.com/questions/682923/dynamically-change-the-choices-in-a-wx-combobox

       http://xoomer.virgilio.it/infinity77/wxPython/Widgets/wx.ItemContainer.html#SetItems



SetItems() 사용하면됨.  -- Clear and set the strings in the control from a list.


myitems 에는 항목이 없지만, instance 생성후에 SetItems() 이용하여 , wx.ComboBox 의 항목 추가함.








반응형

'wxpython' 카테고리의 다른 글

wxpython -- 화면캡쳐후 저장하기  (0) 2015.09.09
Posted by 자유프로그램
,