728x90

DB(Database)/PostgreSQL 5

[PostgreSQL] Python์—์„œ PostgreSQL ์ ‘์†ํ•˜๊ธฐ, python์—์„œ SQL ์ฟผ๋ฆฌ๋ฌธ ์‹คํ–‰ํ•˜๊ธฐ + ์ฟผ๋ฆฌ ์‹คํ–‰ ๊ฒฐ๊ณผ ๋ฐ์ดํ„ฐํ”„๋ ˆ์ž„์œผ๋กœ ๋งŒ๋“ค๊ธฐ

PostgreSQL ์„œ๋ฒ„์— ์ ‘์†ํ•˜๊ธฐ psycopg2 ์„ค์น˜ import psycopg2 conn_string = "host = 'localhost' dbname = 'db๋ช…' user = 'user๋ช…' password = 'ํŒจ์Šค์›Œ๋“œ'" conn = psycopg2.connect(conn_string) cur = conn.cursor() ์œ„์˜ ์ฝ”๋“œ ์‹คํ–‰ ํ›„ SQL ์ฟผ๋ฆฌ๋ฅผ ํŒŒ์ด์ฌ์œผ๋กœ ์‹คํ–‰ ๊ฐ€๋Šฅ import pandas as pd cur.execute("์ฟผ๋ฆฌ๋ฌธ") # ์˜ˆ์‹œ # cur.execute("SELECT * FROM [DB๋ช…];") result = cur.fetchall() # result์— ๊ฒฐ๊ณผ ์ €์žฅ # ์ฟผ๋ฆฌ๋ฌธ ์‹คํ–‰ ๊ฒฐ๊ณผ๋ฅผ pandas dataframe ํ˜•์‹์œผ๋กœ ๋งŒ๋“ค๊ธฐ my_df = pd.DataFra..

[PostgreSQL] PostgreSQL์˜ GUI ํˆด pgAdmin ์‚ฌ์šฉ

sql์„ ์ด์šฉํ•œ ๋ฐ๋ฒ ๊ด€๋ฆฌ ์‹œ csv๋‚˜ ๋‹ค๋ฅธ ํŒŒ์ผ ํ˜•์‹์œผ๋กœ export/import ๋ฅผ ํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฒŒ ๊ฐ€์žฅ ํŽธ๋ฆฌํ•จ ์ €์žฅํ•˜๊ณ  ์‹ถ์€ schemas table ์„ ํƒ ํ›„ Tools -> Import/Export ์„ ํƒ export ํ›„ ํŒŒ์ผ ์ด๋ฆ„ .csv๋กœ ๋ฐ”๊พธ๋ฉด csv๋กœ ์ €์žฅ๋จ

[PostgreSQL] ๋Œ€์šฉ๋Ÿ‰ .sql ๋คํ”„ ํŒŒ์ผ ๋ณต์›ํ•˜๊ธฐ (์œˆ๋„์šฐ ๊ธฐ๋ฐ˜)

๋Œ€์šฉ๋Ÿ‰ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ๊ฒฝ์šฐ ๋คํ”„ ํŒŒ์ผ๋กœ ์ €์žฅ๋˜์–ด ์žˆ๋Š” ๊ฒฝ์šฐ ๋งŽ์Œ. ๋‚ด๊ฐ€ ์‚ฌ์šฉํ–ˆ๋˜ STRING Biological Pathway database์˜ ๊ฒฝ์šฐ ๋คํ”„ํŒŒ์ผ์˜ ํฌ๊ธฐ๋„ 83GB ๋ผ ์ƒ๋‹นํžˆ ์ปธ์Œ... ์•„๋ฌดํŠผ ์ด ๋ช…๋ น ํ•˜๋‚˜๋ฉด ๋Œ€์šฉ๋Ÿ‰ DB ๋คํ”„ํŒŒ์ผ ๋ณต์› ๊ฐ€๋Šฅํ•˜๋‹ค. ํ•˜์ง€๋งŒ ์€๊ทผ ์‹œ๊ฐ„ ๊ฑธ๋ฆฐ๋‹ค๋Š”์  ใ…Žใ……ใ…Ž cmd ์ฐฝ ์—ด๊ณ  ์ž…๋ ฅ psql -U {์œ ์ €๋„ค์ž„} -d {๋คํ”„ํŒŒ์ผ ํ’€๊ณ  ์‹ถ์€ DB๋ช…} -a -f {๋คํ”„ํŒŒ์ผ์œ„์น˜} EX) psql -U postgres -d [mydbname] -a -f C:\Users\Downloads\[ํŒŒ์ผ๋ช…].sql

[PostgreSQL] PostgreSQL ๋‹ค์šด๋กœ๋“œ (WINDOW ์šด์˜์ฒด์ œ์— ์„ค์น˜)

DBMS(DataBase Management System) ์ค‘ ํ•˜๋‚˜ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ๊ด€๋ฆฌ, ์šด์˜ํ•˜๋Š” ์†Œํ”„ํŠธ์›จ์–ด ์‚ฌ์šฉ์ž๋‚˜ ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ --> DBMS๊ฐ€ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐ์ดํ„ฐ์— ๋™์‹œ์— ์ ‘์†ํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฅผ ๊ณต์œ ํ•จ https://www.postgresql.org/download/windows/ PostgreSQL: Windows installers Windows installers Interactive installer by EDB Download the installer certified by EDB for all supported PostgreSQL versions. This installer includes the PostgreSQL server, pgAdmin; a graphical tool for managi..

728x90