일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
- GIT
- dataframe
- Redshift
- PySpark
- math
- Google Excel
- array
- google apps script
- string
- Mac
- 파이썬
- PANDAS
- Tkinter
- Apache
- c#
- Google Spreadsheet
- django
- hive
- Kotlin
- Github
- SQL
- Excel
- PostgreSQL
- numpy
- Python
- matplotlib
- gas
- Java
- list
- Today
- Total
목록SQL (63)
달나라 노트
pg_catalog를 이용하면 DB에 있는 Schema list를 얻을 수 있습니다. select * from pg_catalog.pg_namespace ; pg_catalog의 pg_namespace에서 select를 하면 schema list와 schema의 owner id를 얻을 수 있습니다. select * from pg_catalog.pg_user ; pg_catalog.pg_user에는 user 정보가 저장되어있습니다. pg_user의 usesysid 컬럼과 pg_namespace의 nspowner 컬럼이 user id를 의미하므로 이 두 컬럼을 join하서 사용하면 됩니다.
pyhive 라이브러리는 python에서 서버에 접근하여 Hive SQL query를 실행할 수 있도록 해줍니다. 이번에는 pyhive 라이브러리를 이용해서 Hive query를 돌리는 예시를 봐봅시다. 아래 코드가 가장 기본적인 pyhive 사용 예시입니다. from pyhive import hive import pandas as pd hive_con = hive.Connection( host='test_host', port=10000, username='test_user_id', password='test_user_password', database='default', auth='LDAP' ) cursor = hive_con.cursor() test_query = ''' select tt.id, tt..
Presto에서 날짜나 시간을 더하고 빼기 위해선 interval 함수를 사용하면 됩니다. select current_date, --> 2022-01-14 timestamp '2022-01-14 15:23:43' + interval '1' second, --> 2022-01-14 15:23:44 timestamp '2022-01-14 15:23:43' - interval '1' second, --> 2022-01-14 15:23:42 timestamp '2022-01-14 15:23:43' + interval '1' minute, --> 2022-01-14 15:24:43 timestamp '2022-01-14 15:23:43' - interval '1' minute, --> 2022-01-14 15:2..