Naming

module_name, package_name, ClassName, method_name, ExceptionName, function_name, GLOBAL_CONSTANT_NAME, global_var_name, instance_var_name, function_parameter_name, local_var_name.

Names to Avoid

single character names except for counters or iterators

dashes (-) in any package/module name

__double_leading_and_trailing_underscore__ names (reserved by Python)

Naming Convention

"Internal" means internal to a module or protected or private within a class.

Prepending a single underscore (_) has some support for protecting module variables and functions (not included with import * from). Prepending a double underscore (__) to an instance variable or method effectively serves to make the variable or method private to its class (using name mangling).

Place related classes and top-level functions together in a module. Unlike Java, there is no need to limit yourself to one class per module.

Use CapWords for class names, but lower_with_under.py for module names. Although there are many existing modules named CapWords.py, this is now discouraged because it's confusing when the module happens to be named after a class. ("wait -- did I write import StringIO or from StringIO import StringIO?")

Guidelines derived from Guido's Recommendations

Type Public Internal

Packages lower_with_under

Modules lower_with_under _lower_with_under

Classes CapWords _CapWords

Exceptions CapWords

Functions lower_with_under() _lower_with_under()

Global/Class Constants CAPS_WITH_UNDER _CAPS_WITH_UNDER

Global/Class Variables lower_with_under _lower_with_under

Instance Variables lower_with_under _lower_with_under (protected) or __lower_with_under (private)

Method Names lower_with_under() _lower_with_under() (protected) or __lower_with_under() (private)

Function/Method Parameters lower_with_under

Local Variables lower_with_under

Main

Aliyun RDS를 구매한 후 데이터베이스, 계정 생성 후 외부 접속하는 방법을 정리 하려고 합니다.


1. 데이터 베이스 생성

1-1) 데이터 베이스 추가 버튼 클릭

[그림 1-1] 데이터 베이스 추가 버튼

1-2) 데이터 베이스 정보 입력 및 추가

[그림 1-2] 데이터 베이스 추가 입력 폼

[1] 데이터 베이스 이름

[2] 인코딩 방식 설정

[3] 데이터 베이스 추가 하기


2. 계정 생성

2-1) 계정 추가 버튼 클릭

[그림 2-1] 계정 생성 추가 버튼

2-2) 계정 정보 입력 및 추가

[그림 2-2] 계정 추가 입력 폼

[1]계정 ID

[2] 쓰기 / 읽기 권한 부여

[3] 패스워드 및 패스워드 호가인

[4] 계정 추가 하기


3. 외부 접속 허용

3-1) security group 추가하기 버튼 클릭

[그림 3-1] security group 추가 버튼

3-2) security group 추가하기

[그림 3-2] security group 추가 하기

security group 이름과 허용 IP에서 %를 넣고 추가하기 버튼을 클릭


1. 테스트할 테이블 생성 코드

[그림 1-1] 테스트할 테이블 및 데이터


CREATE TABLE `tbl_condition_test` (
    `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    `col1` INT(10) UNSIGNED NULL DEFAULT NULL,
    `col2` INT(10) UNSIGNED NULL DEFAULT NULL,
    PRIMARY KEY (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=MyISAM

2. 샘플 데이터 삽입 코드

INSERT INTO `test` (`id`, `col1`, `col2`) VALUES (1, NULL, 11);
INSERT INTO `test` (`id`, `col1`, `col2`) VALUES (2, 2, 12);
INSERT INTO `test` (`id`, `col1`, `col2`) VALUES (3, 3, 13);
INSERT INTO `test` (`id`, `col1`, `col2`) VALUES (4, NULL, 14);
INSERT INTO `test` (`id`, `col1`, `col2`) VALUES (5, 5, 15);
INSERT INTO `test` (`id`, `col1`, `col2`) VALUES (6, 6, 21);
INSERT INTO `test` (`id`, `col1`, `col2`) VALUES (7, 7, 22);
INSERT INTO `test` (`id`, `col1`, `col2`) VALUES (8, 8, 23);
INSERT INTO `test` (`id`, `col1`, `col2`) VALUES (9, NULL, 24);
INSERT INTO `test` (`id`, `col1`, `col2`) VALUES (10, 10, 25);


3. 상황을 하나 예로 들어서 조건문을 어떻게 사용하는지 알아보려고 합니다.

[예시] 만약 col1 값이 NULL이면 col2 값을 선택하고 만약 col1값이 NULL이 아니면 col1값을 선택한다.

3-1) IF 이용하기

SELECT IF( col1 IS NULL, col2, col1) FROM tbl_condition_test

3-2) IFNULL 이용하기

SELECT IFNULL(col1, col2) FROM tbl_condition_test

3-3) CASE WHEN THEN ELSE END 이용하기 

여기에는 위 조건에 하나 더 추가하여 col1 값이 10이면 100을 선택한다로 해보겠습니다.

SELECT CASE WHEN col1 IS NULL THEN col2 
			WHEN col1 = 10 THEN 100 
			ELSE col1 END
FROM tbl_condition_test


+ Recent posts