작성 시 깨짐현상

1. 그분선, 인용문, 표는 "마크다운"작성 후, 글을 수정하면 기본모드에서 형식이 tistory인용으로 변경됨.

2. 링크 입력 시, 링크명과 URL, 설명이 그대로 표시됨.

 

※ Markdown 개발자 사이트 : https://daringfireball.net/projects/markdown/

※ Github Markdown 설명 :https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax 

Markdown Test

======================

Header1

Header2

Header3

Header4

Header5
Header6
# Markdown Test
======================
# Header1

## Header2

### Header3

#### Header4

##### Header5

###### Header6

강조

xx 이탤릭
xx 볼드

xxx 취소

*xx 이탤릭*
**xx 볼드**
~~xxx 취소~~

포맷 무시

*강조* 안하기

### 포맷 무시
\*강조\* 안하기

번호 목록

  1. 하나
  2. 1번 다시
1. 하나
2. 둘
3. 셋
1. 1번 다시

글머리 기호 목록

  • 대쉬
  • 별표
  • 더하기
- 대쉬
* 별표
+ 더하기

번호, 글머리 같이

  1. 하나
    • 대쉬1
    1. 하나2
    2. 둘2
    • 대쉬2
1.  하나
    -   대쉬1
    1.  하나2
    2.  둘2
    -   대쉬2
2.  둘
3.  셋

링크

[Google] (https://google.com) "설명"
[상대적 참조] [Naver]
[Naver] : https://naver.com

[Google] (https://google.com) "설명"
[상대적 참조] [Naver]
[Naver] : https://naver.com

구분선






---
***
* * *
- - -

인용구

인용문

인용문2

인용문3

> 인용문

>> 인용문2

>>> 인용문3

코드블럭

s = "Python syntax highlighting"
print s
```python
s = "Python syntax highlighting"
print s
```

의미 기본값
static 유형(기준) 없음 / 배치 불가능 static
relative 요소 자신을 기준으로 배치  
absolute 위치 상 부모(조상)요소를 기준으로 배치  
fixed 브라우저 창을 기준으로 배치  

| 값 | 의미 | 기본값 |
| --- | :-: | --: |
| `static` | 유형(기준) 없음 / 배치 불가능 | `static` |
| `relative` | 요소 자신을 기준으로 배치 | |
| `absolute` | 위치 상 부모(조상)요소를 기준으로 배치 | |
| `fixed` | 브라우저 창을 기준으로 배치 | |

이모지

😄
https://steemit.com/steemkr-guide/@snow-airline/steemkr-quick-start-guide

😄
https://steemit.com/steemkr-guide/@snow-airline/steemkr-quick-start-guide

이미지

대체 텍스트(alternative text)를 입력하세요!Kayak

### 이미지

![대체 텍스트(alternative text)를 입력하세요!](http://www.gstatic.com/webp/gallery/5.jpg "링크 설명(title)을 작성하세요.")

![Kayak][logo]

[logo]: http://www.gstatic.com/webp/gallery/2.jpg "To go kayaking."
728x90

'tistory' 카테고리의 다른 글

마크다운 문법  (0) 2021.04.27
Google Adsense 배너만 보일 때  (0) 2021.04.01
highlight.js 적용하기  (0) 2019.12.30

 

SettingWithCopyWarning 경고가 계속 발생할 때 해결방안

 

1) Dataframe의 slice를 복사 후 사용한다.

  # df = df[(df.A > 10) & (df.B < 5)] 아래 구분으로 변경한다.
  df = df[(df.A > 10) & (df.B < 5)].copy()
  df['1/PER'] = 1 / df['PER']

2) 경고를 끈다

import pandas as pd

# 경고를 끈다 (기본값: 'warn')
pd.set_option('mode.chained_assignment',  None)

# 중략...
df = df[(df.A > 10) & (df.B < 5)]
df['1/PER'] = 1 / df['PER']

 

end.

728x90

SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)'))

 

인증서 오류 시 --trusted-host 옵션을 사용한다.

 

$ pip install requests bs4 lxml openpyxl numpy
There was a problem confirming the ssl certificate

$ pip --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org install requests bs4 lxml openpyxl numpy

 

 

Usage:   
  pip <command> [options]

Commands:
  install               Install packages.
  download          Download packages.
  uninstall            Uninstall packages.
  freeze               Output installed packages in requirements format.
  list                   List installed packages.
  show                Show information about installed packages.
  check               Verify installed packages have compatible dependencies.
  config              Manage local and global configuration.
  search              Search PyPI for packages.
  cache               Inspect and manage pip's wheel cache.
  index               Inspect information available from package indexes.
  wheel              Build wheels from your requirements.
  hash               Compute hashes of package archives.
  completion      A helper command used for command completion.
  debug            Show information useful for debugging.
  help               Show help for commands.

 

General Options:
  -h, --help        Show help.
  --isolated        Run pip in an isolated mode, ignoring environment variables and user configuration.
  -v, --verbose    Give more output. Option is additive, and can be used up to 3 times.     
  -V, --version    Show version and exit.

  --trusted-host <hostname>

   Mark this host or host:port pair as trusted, even though it does not have valid or any HTTPS.

  ... 중략 ...

 

end.

728x90

SQLite 링크: https://www.sqlite.org/index.html

 

Python SQLite : https://docs.python.org/ko/3/library/sqlite3.html

 

- 내장 가능한 오픈소스 데이터베이스이다. C로 작성됐으며 일반적인 SQL로 쿼리가 가능한다.

- SQL은 다양한 플랫폼에서 이식됨.

 

1. 장점

- 관계형 데이터베이스 역할을 하고, 트랜잭션을 지원함.

- 전체 텍스트 인덱스, JSON 데이터 지원 등 고급 데이터베이스 기능을 지원함.

- 단일 독립형 바이너리이므로 앱과 함께 배포하고 앱과 이동하기 쉽다.

 

2. 특징

- 데이터형식은 TEXT, NUMERIC, INTEGER, REAL, BLOB 로 소수다. 일자는 함수를 제공한다.

   https://www.sqlite.org/lang_datefunc.html

- SQLite는 단일 애플리케이션이 적합하고, 동시 사용자는 MySQL 또는 내장DB중에는 버클리DB가 적당함.

  버클리DB 엔진 성능은 SQLite를 못 따라감.

 

9. 참조

9.1 isolation_level : https://www.sqlite.org/lang_transaction.html

 - None : autommit
 - 'DEFERRED': (default) 쓰기모드에서 트랜잭션 시작됨. commit / rollback 처리 필요.
 - 'IMMEDIATE': 데이터베이스 연결 즉시 트랜잭션 시작.
 - 'EXCLUSIVE': IMMEDIATE와 유사하지만 트랜잭션 동안 다른 데이터베이스 연결이 데이터베이스 읽는 것을 방지함.

9.2 다중 스레드 응용 프로그램에서 SQLite 사용

 - 관련글: https://docs.python.org/ko/3/library/sqlite3.html (sqlite3.threadsafety)

             https://www.sqlite.org/threadsafe.html

 - python / sqlite3 에서 qlite3.threadsafety=1 로 스레드는 모듈을 공유할 수 있지만, 연결을 공유할 수 없음.

   연결 시 check_same_thread=True(기본값)를 False로 변경하면, 다른 스레드로 공유가능함.

   단, 쓰기에서는 직렬화 해서 사용해야 안전한데 현재 sqlite3에서는 지원이 안되는 것 같음.

  • Python Sample Code
import sqlite3

# 실행위치에 파일이 생성되고, 상대위치를 지정하면 실행 최상위를 계산해서 수행함.
conn = sqlite3.connect('./universe_price.db', isolation_level=None)
cur = conn.cursor()

def create_table():
  cur.execute('''CREATE TABLE IF NOT EXISTS 
  BALANCE
  (
    CODE VARCHAR(6) PRIMARY KEY,
    BID_PRICE INT(20) NOT NULL,
    QUANTITY INT(20) NOT NULL,
    CREATED_AT VHARCHAR(14) NOT NULL,
    WILL_CLEAR_AT VARCHAR(14)
  )
  ''')

# 단건 등록 테스트
def test_insert_row():
  sql = """INSERT INTO BALANCE(CODE, BID_PRICE, QUANTITY, CREATED_AT, WILL_CLEAR_AT) VALUES
  (?, ?, ?, ?, ?)
  """
  cur.execute(sql, ('005930', 70000, 10, '20201222', 'today'))
  # conn.commit()
  print(cur.rowcount)

# 복수건 등록 테스트
def test_insert_rows():
  sql = """INSERT INTO BALANCE(CODE, BID_PRICE, QUANTITY, CREATED_AT, WILL_CLEAR_AT) VALUES
  (?, ?, ?, ?, ?)
  """
  stocks = [
    ('010060', 109500, 10, '20201222', 'today'),
    ('005380', 168000, 10, '20201222', 'today'),
    ('336260', 39700, 10, '20201222', 'today')
  ]
  cur.executemany(sql, stocks)
  # conn.commit()
  print('insert row count: {}'.format(cur.rowcount))

# 단건 조회 테스트
def test_select_one():
  cur.execute('SELECT * FROM BALANCE')
  row = cur.fetchone()
  print(row)

# 전체 조회 테스트
def test_select_all():
  cur.execute('SELECT * FROM BALANCE WHERE BID_PRICE > :BID_PRICE', {'BID_PRICE':50000})
  rows = cur.fetchall()
  print('# 전체 조회 테스트')
  for row in rows:
    code, bid_price, quantity, created_at, will_clear_at = row
    print(row)

# 일부건 패치 테스트
def test_select_many(row_count):
  cur.execute('SELECT * FROM BALANCE')
  rows = cur.fetchmany(row_count)
  print('# 일부건 조회 테스트')
  for row in rows:
    code, bid_price, quantity, created_at, will_clear_at = row
    print(row)

def close_conn():
  conn.close()

if __name__ == "__main__":
  create_table()
  # test_insert_row()
  # test_insert_rows()
  test_select_all()
  test_select_many(2)

close_conn()

end.

 

728x90

+ Recent posts