묻고 답해요
131만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결따라하며 배우는 노드, 리액트 시리즈 - 레딧 사이트 만들기(NextJS)(Pages Router)
엔티티 모두 작성 후 서버 실행 시 에러가 발생합니다
서버 실행 시 해당 에러가 발생해서 질문 남깁니다문제 파악에 도움될까해서 data-source.ts, server.ts 파일도 첨부합니다
-
미해결다양한 사례로 익히는 SQL 데이터 분석
pandas 연계시 오류.....
(아나콘다를 깔고나서 새 파일에서 뭘 수정하려고하면 바로 연결이 끊기는 문제가 생겨 주피터 노트북으로 설치하였습니다. 필요한 라이브러리들은 모두 따로 설치하였습니다.)버전은 아래와 같습니다.오류가 발생하는 부분은 이 부분인데query문이 있는 셀의 전체 오류문은 아래와 같습니다--------------------------------------------------------------------------- UnicodeDecodeError Traceback (most recent call last) Cell In[12], line 4 1 query = """ 2 select * from nw.customers 3 """ ----> 4 df = pd.read_sql_query(sql=query, con=postgres_engine) 5 df.head(10) File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\io\sql.py:485, in read_sql_query(sql, con, index_col, coerce_float, params, parse_dates, chunksize, dtype, dtype_backend) 482 dtype_backend = "numpy" # type: ignore[assignment] 483 assert dtype_backend is not lib.no_default --> 485 with pandasSQL_builder(con) as pandas_sql: 486 return pandas_sql.read_query( 487 sql, 488 index_col=index_col, (...) 494 dtype_backend=dtype_backend, 495 ) File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\io\sql.py:851, in pandasSQL_builder(con, schema, need_transaction) 848 raise ImportError("Using URI string without sqlalchemy installed.") 850 if sqlalchemy is not None and isinstance(con, (str, sqlalchemy.engine.Connectable)): --> 851 return SQLDatabase(con, schema, need_transaction) 853 warnings.warn( 854 "pandas only supports SQLAlchemy connectable (engine/connection) or " 855 "database string URI or sqlite3 DBAPI2 connection. Other DBAPI2 " (...) 858 stacklevel=find_stack_level(), 859 ) 860 return SQLiteDatabase(con) File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\io\sql.py:1576, in SQLDatabase.__init__(self, con, schema, need_transaction) 1574 self.exit_stack.callback(con.dispose) 1575 if isinstance(con, Engine): -> 1576 con = self.exit_stack.enter_context(con.connect()) 1577 if need_transaction and not con.in_transaction(): 1578 self.exit_stack.enter_context(con.begin()) File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3268, in Engine.connect(self) 3245 def connect(self) -> Connection: 3246 """Return a new :class:`_engine.Connection` object. 3247 3248 The :class:`_engine.Connection` acts as a Python context manager, so (...) 3265 3266 """ -> 3268 return self._connection_cls(self) File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:145, in Connection.__init__(self, engine, connection, _has_events, _allow_revalidate, _allow_autobegin) 143 if connection is None: 144 try: --> 145 self._dbapi_connection = engine.raw_connection() 146 except dialect.loaded_dbapi.Error as err: 147 Connection._handle_dbapi_exception_noconnection( 148 err, dialect, engine 149 ) File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py:3292, in Engine.raw_connection(self) 3270 def raw_connection(self) -> PoolProxiedConnection: 3271 """Return a "raw" DBAPI connection from the connection pool. 3272 3273 The returned object is a proxied version of the DBAPI (...) 3290 3291 """ -> 3292 return self.pool.connect() File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:452, in Pool.connect(self) 444 def connect(self) -> PoolProxiedConnection: 445 """Return a DBAPI connection from the pool. 446 447 The connection is instrumented such that when its (...) 450 451 """ --> 452 return _ConnectionFairy._checkout(self) File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:1269, in _ConnectionFairy._checkout(cls, pool, threadconns, fairy) 1261 @classmethod 1262 def _checkout( 1263 cls, (...) 1266 fairy: Optional[_ConnectionFairy] = None, 1267 ) -> _ConnectionFairy: 1268 if not fairy: -> 1269 fairy = _ConnectionRecord.checkout(pool) 1271 if threadconns is not None: 1272 threadconns.current = weakref.ref(fairy) File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:716, in _ConnectionRecord.checkout(cls, pool) 714 rec = cast(_ConnectionRecord, pool._do_get()) 715 else: --> 716 rec = pool._do_get() 718 try: 719 dbapi_connection = rec.get_connection() File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:169, in QueuePool._do_get(self) 167 return self._create_connection() 168 except: --> 169 with util.safe_reraise(): 170 self._dec_overflow() 171 raise File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:146, in safe_reraise.__exit__(self, type_, value, traceback) 144 assert exc_value is not None 145 self._exc_info = None # remove potential circular references --> 146 raise exc_value.with_traceback(exc_tb) 147 else: 148 self._exc_info = None # remove potential circular references File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\impl.py:167, in QueuePool._do_get(self) 165 if self._inc_overflow(): 166 try: --> 167 return self._create_connection() 168 except: 169 with util.safe_reraise(): File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:393, in Pool._create_connection(self) 390 def _create_connection(self) -> ConnectionPoolEntry: 391 """Called by subclasses to create a new ConnectionRecord.""" --> 393 return _ConnectionRecord(self) File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:678, in _ConnectionRecord.__init__(self, pool, connect) 676 self.__pool = pool 677 if connect: --> 678 self.__connect() 679 self.finalize_callback = deque() File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:902, in _ConnectionRecord.__connect(self) 900 self.fresh = True 901 except BaseException as e: --> 902 with util.safe_reraise(): 903 pool.logger.debug("Error on connect(): %s", e) 904 else: 905 # in SQLAlchemy 1.4 the first_connect event is not used by 906 # the engine, so this will usually not be set File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\util\langhelpers.py:146, in safe_reraise.__exit__(self, type_, value, traceback) 144 assert exc_value is not None 145 self._exc_info = None # remove potential circular references --> 146 raise exc_value.with_traceback(exc_tb) 147 else: 148 self._exc_info = None # remove potential circular references File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\pool\base.py:898, in _ConnectionRecord.__connect(self) 896 try: 897 self.starttime = time.time() --> 898 self.dbapi_connection = connection = pool._invoke_creator(self) 899 pool.logger.debug("Created new connection %r", connection) 900 self.fresh = True File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\create.py:637, in create_engine.<locals>.connect(connection_record) 634 if connection is not None: 635 return connection --> 637 return dialect.connect(*cargs, **cparams) File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\default.py:616, in DefaultDialect.connect(self, *cargs, **cparams) 614 def connect(self, *cargs, **cparams): 615 # inherits the docstring from interfaces.Dialect.connect --> 616 return self.loaded_dbapi.connect(*cargs, **cparams) File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\psycopg2\__init__.py:122, in connect(dsn, connection_factory, cursor_factory, **kwargs) 119 kwasync['async_'] = kwargs.pop('async_') 121 dsn = _ext.make_dsn(dsn, **kwargs) --> 122 conn = _connect(dsn, connection_factory=connection_factory, **kwasync) 123 if cursor_factory is not None: 124 conn.cursor_factory = cursor_factory UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb8 in position 63: invalid start byte
-
미해결데이터 분석 SQL Fundamentals
질문있씁니다!!
제가 현장에서 Oracle 과 Tibero 를 돌아가면서 쓰고있는데 본강의에 듣기에 적합할까요?
-
미해결데이터 분석 SQL Fundamentals
스칼라 서브쿼리 실습 - 01: 7분 56초 질문
해당 쿼리에서 왜 같은 행이 3배로 늘어나게 되는 것인지 궁금합니다. 셀프조인을 하면 원래 3배로 늘어나는 걸까요?감사합니다.
-
해결됨[C#/.NET 8.0]어서와, Blazor Server는 처음이지?
수업자료가 어디있는 거죠?
위치를 모르겠네요ㅠ
-
해결됨데이터 분석 SQL Fundamentals
[서브 쿼리 실습 02 - 5:57] 상관 서브쿼리 관련 질문
안녕하세요, 강의 너무 잘 듣고 있습니다.서브 쿼리 실습 -02 강의 5:57에 나오는 부분에서 하나 궁금한 점이 있어서 문의드립니다.select * from hr.emp_hist_01 a where todate = (select max(todate) from hr.emp_hist_01 x where x.empno = a.empno);위 쿼리에서 서브쿼리가 9999-12-31로 단일 값이 나올 것으로 생각했는데, 아래 테이블 12행에 보면 1983-12-24 데이터도 있어서요.서브쿼리에 group by empno가 없는데 어떻게 각 empno별 max(todate) 값을 가져오는지 궁금합니다.group by empno가 없으면 그냥 x.empno = a.empno로 조인을 한 뒤 전체 데이터에서 max(todate)값을 가져오는 걸로 이해했는데 아닌 걸까요? 감사합니다.
-
해결됨[C#/.NET 6.0]어서와, Blazor WebAssembly는 처음이지?
PostgreSQL 16 사용 중인데 복원시 에러 가 발생합니다.
학습 자료에 올라와있는 자료로 복원시 에러가 발생합니다.
-
미해결따라하며 배우는 NestJS
port 5432 failed: recived invalid response to ssl negotiation
이런 오류메세지가 나오는데 방법좀 부탁드립니다. nestJS서버는 5432포트로 돌아가고 있습니다!!
-
해결됨데이터 분석 SQL Fundamentals
select문 질문
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.안녕하세요.아주 기초적인 질문이 있습니다.-- 고객명 Antonio Moreno이 1997년에 주문한 주문 정보를 주문 아이디, 주문일자, 배송일자, 배송 주소를 고객 주소와 함께 구할것.SELECT contact_name, address, order_id, order_date, shipped_date, ship_addressFROM nw.customers aJOIN nw.orders b ON a.customer_id = b.customer_idWHERE a.contact_name = 'Antonio Moreno'AND b.order_date BETWEEN to_date('19970101', 'yyyymmdd') AND to_date('19971231', 'yyyymmdd'); 위 코드처럼 select문에서 alias를 빼고 작성해도 문제가 없이 나오는데 큰 의미는 없는건가요?어떤 테이블에서 가져온 컬럼값인지 명확히 해주기위해서 필요한 것인가요? alias를 반드시 붙혀야만 실행되는 코드들도 있던데, 차이점이 궁금합니다. SQL을 배운 지 얼마되지 않아 이렇게 질문을 남깁니다.
-
해결됨데이터 분석 SQL Fundamentals
with절 질문
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.안녕하세요!조인 실습 -2를 수강중에 with절이 나와서 이해를 잘 못하고 있습니다. 본 강의를 수강 전에 기초 sql강의를 통해 기초는 닦았지만 with문은 배우지 않아 강의를 따라가기 힘이 듭니다. 구글링을 하여 찾아보아도 이해가 잘 가지 않습니다 ㅠㅠ 혹시 추가적인 설명을 부탁드려도 될까요?
-
해결됨데이터 분석 SQL Fundamentals
MSSQL
안녕하세요,MSSQL 를 사용하는 경우도만들어주신 두 SQL 강의가 도움이 될까요?
-
미해결다양한 사례로 익히는 SQL 데이터 분석
시각화 그래프가 안보여요
안녕하세요. 매출 분석01 - 일/주/월/분기별 매출액 및 주문건수 시각화 하기강의를 들으면서 코드를 실행하는데 그래프가 이러타할 오류없이 나타나지 않아서 글 작성합니다. 각각 라이브러리의 버전은 아래와 같습니다. 쥬피터 파일 내의 [일별 매출 시각화] 에 대한 코드를 실행하는데, 쿼리가 들어간 데이터 프레임까지는 잘 실행이 되는데, 그래프를 그리는 코드를 실행하면 그래프가 나타나지 않습니다. <스크린샷1 - 데이터 프레임은 잘 나타남> <스크린 샷2 - 그래프 그리는 코드 실행시 그래프가 나타나지 않음> <스크린 샷 3 - 그래프 그리는 코드 실행시 그래프가 나타나지 않음> <스크린 샷4 - 키 에러라고 뜨는데 왜 이렇게 나타나는지 잘 모르겠어요. 코드를 따로 바꾸거나 수정하지 않았습니다. > 터미널이 이상해서 그런가하고 전체적으로 다 끄고 다시 켜서 실행해 봤는데도 나타나지 않아서 질문 드립니다.
-
미해결따라하며 배우는 NestJS
repository.ts 에서 method 를 가져 오고 싶은데, 해당 메소드가 없다고 뜨네요
현재, nestjs로 게시판 만들기를 학습 하고 있는데,에러에, 에러에, 에러에, 에러의 연속이네요... 데이터베이스 연결이 안 되는 에러를 계속 보다가 어찌 어찌 해결은 했는데ERROR [TypeOrmModule] Unable to connect to the database. 이젠 메소드를 찾을 수 없다는 에러가 계속 뜨네요...뭐가 문제인 것일까요... 후우 또 열심히 검색을 해봐야겠습니다... // board.repository.ts import { EntityRepository, Repository } from "typeorm"; import { Board } from "./board.entity"; import { CreateBoardDto } from "./dto/create-board.dto"; import { BoardStatus } from "./board-status.enum"; @EntityRepository(Board) export class BoardRepository extends Repository<Board> { async createBoard(createBoardDto: CreateBoardDto) : Promise<Board> { const { title, description } = createBoardDto; const board = this.create({ title, description, status: BoardStatus.PUBLIC }) await this.save(board); return board; } }// boards.service.ts import { Injectable, NotFoundException } from '@nestjs/common'; import { BoardStatus } from './board-status.enum'; import { CreateBoardDto } from './dto/create-board.dto'; import { InjectRepository } from '@nestjs/typeorm'; import { Board } from './board.entity'; import { Repository } from 'typeorm'; // import { BoardRepository } from './board.repository'; @Injectable() export class BoardsService { constructor( @InjectRepository(Board) private boardRepository: Repository<Board>, ) {} createBoard(createBoardDto: CreateBoardDto) : Promise<Board> { return this.boardRepository.createBoard(createBoardDto); } async getBoardById(id: number): Promise <Board> { const found = await this.boardRepository.findOne(id); if(!found) { throw new NotFoundException(`Can't find board with id ${id}`) } return found; }
-
미해결따라하며 배우는 노드, 리액트 시리즈 - 레딧 사이트 만들기(NextJS)(Pages Router)
회원가입 누르면 404에러가 뜹니다 ;-;
안녕하세요 ;-;회원가입 누르니 404에러가 뜹니다..완성 코드랑 비교해서 봐도 똑같은데 어떤 문제인지 모르겠스빈다... next.js가 13이긴 합니다만 ;-; 그 이유 일까요?.. 어디를 살펴보면 될까요?;-;
-
미해결데이터 분석 SQL Fundamentals
Non Equi 조인과 Cross 조인 실습 강의 내용에 대해 질문드립니다
선생님 안녕하세요강의 잘 보고 있습니다강의 중간(10:20~25초 사이)내용에 대해 확인하고 싶은 부분이 있습니다수업내용중 아래의 sql로 질의할때-- 직원 급여의 이력정보를 나타내며, 해당 급여를 가졌던 시점에서의 부서번호도 함께 가져올것. select * from hr.emp_salary_hist a join hr.emp_dept_hist b on a.empno = b.empno; record 4번 데이터의 deptno 값 30이 출력된다고 하셨습니다만 a.fromdate between b.fromdate and b.todate위의 between 조건으로 조인해서 sql로 질의했을 때에출력되는 결과물은record 3번 데이터 deptno 값 20이 출력되는데, record 3번의 a.fromdate (1982-01-01)값만이조인된 b.fromdate(1981-04-01) and b.todate(9999-12-31)의 범위에 해당되어 출력되는 인식인데 (제가 잘못 이해했을 수도 있습니다만... )어떻게 deptno값 30이 출력되는지가 궁금합니다
-
미해결따라하며 배우는 NestJS
컨트롤러에선 async/await 사용하지 않아도 되는 이유
서비스에서 async/await을 사용하는데컨트롤러에서는 사용하지 않아도 되는것이 의문입니다. express 환경에서는 컨트롤러까지 비동기처리를 해야데이터가 잘 넘겨졌던걸로 기억해서nestjs의 기능인가 싶어서 질문드립니다!
-
미해결따라하며 배우는 노드, 리액트 시리즈 - 레딧 사이트 만들기(NextJS)(Pages Router)
nextjs버젼에 대해서 질문드립니다.
현재 강의가 nextjs12로작성된듯한데 create-app 으로 12버젼을 지정해도 14버전이 깔려버립니다. 혹시 강의자체를 리뉴얼 하실 계획이 있으신가요?
-
해결됨다양한 사례로 익히는 SQL 데이터 분석
ntile 정규분포에 관하여 ... 향후 일을 하게 될 시
강의를 듣는 도중, ntile()의 경우, 분포가 skew가 심하면(정규분포가 아니라면), 순위를 매길 때, 문제가 생김을 배울 수 있었습니다. Q1. 저는 왜곡이 되어있는 걸 보자마자, 차라리 판다스나 Spark SQL로 데이터를 정규화 한뒤에, 시각화를 하는게 더 빠르지 않을까? 하는 생각이 들었는데요, 기업에서 일을 하게 될 때, 어떤 경우에 SQL을 쓰는지가 궁금합니다.저는 강사님의 강의를 수강하며, python 데이터 분석 -> 머신러닝 -> 딥러닝 이후, 현재 SQL강의를 수강하고 있습니다. 희망직무는 데이터 사이언스트 및 데이터 엔지니어를 희망하는데, 항상 채용공고를 보면, python 능력도 중요하지만 고급 SQL 능력도 자격요건으로 되어 있는 경우가 많았습니다.Q2. 현업에서 데이터를 가공하거나 처리할 때, 오히려 프로그래밍언어보다는 SQL를 훨씬 많이 쓴다고 하는데, Q1처럼 때에 따라 유동적으로 쓰는 것인지, 아니면 앞으로 데이터 분석을 연습할 때도, (이를 테면, 캐글과 같은) 파이썬 보다는 SQL위주로 연습하는 것이 더 적합한 건지 여쭙고 싶습니다. Q3. 이건 머신러닝과 관련된 이야기지만, 이렇게까지 skew가 개선되지 않을 때는 어떻게 해야하나요?from sklearn.preprocessing import StandardScaler # OverSampling을 해도 Skew가 개선되지 않음 # UnderSampling을 하면 데이터가 줄어들기 때문에, 사용에 유의가 필요하나 skew가 # 너무 심하기 때문에 사용함. from imblearn.under_sampling import CondensedNearestNeighbour from scipy import stats import numpy as np def log_transform(column): return np.log1p(column) scaler = StandardScaler() df["freq"] = log_transform(df["freq"]) df["freq"] = scaler.fit_transform(df[["freq"]]) cnn = CondensedNearestNeighbour(sampling_strategy='majority', random_state=42) X_resampled, y_resampled = cnn.fit_resample(df[["freq"]], df["user_id"].values) resampled_df = pd.DataFrame(data=X_resampled, columns=["freq"]) print(resampled_df) ####### freq 0 -0.352373 1 -0.352373 2 -0.352373 3 -0.352373 4 2.495698 ... ... 2557 -0.352373 2558 3.642937 2559 -0.352373 2560 -0.352373 2561 -0.352373 [2562 rows x 1 columns] ######### resampled_df["freq"] = log_transform(resampled_df["freq"]) resampled_df["freq"].skew() ### 2.4721717038971214
-
미해결데이터 분석 SQL Fundamentals
join 결과 테이블 집합 레벨
안녕하세요 [ Group by 실습 01 ] 강의를 듣다가 실습 문제에서 결과 값이 이해가 되지 않아 질문드립니다.-- 부서명 SALES와 RESEARCH 소속 직원별로 과거부터 현재까지 모든 급여를 취합한 평균 급여(with 절로 풀기)수업 듣기 전, 위의 문제에서 with 절 안의 테이블을 만들려고 아래와 같이 적었습니다. (같은 테이블 결과값이 나오는지 확인만 하려고 select 뒤에 구체적인 컬럼을 적지 않고 * 를 적었습니다.) [수업 전 작성 답안 & 결과 테이블]select *from hr.emp ajoin hr.dept b on a.deptno = b.deptnojoin hr.emp_salary_hist c on a.empno = c.empnowhere b.dname in('SAELS','RESEARCH');--> dname 에 research 만 나타납니다. [강의 예시 답안]select *from hr.dept ajoin hr.emp b on a.deptno = b.deptnojoin hr.emp_salary_hist c on b.empno = c.empnowhere a.dname in('SALES','RESEARCH');--> 나와야 하는 결과값 잘 나옴. 위의 제가 적은 답안에서 어떤점이 잘못 되었는지 도무지 보이지않아서 질문드립니다.join 만 적을시 inner join 이 적용되므로, 집합 레벨은 모든 테이블의 join 될 수 있는 모든 컬럼값 끼리 붙을 텐데, 그러면 어떤 테이블을 먼저 적던지 순서에 상관 없이 같은 결과 값이 나와야 하는 것 아닌가요?inner join 할 시에 염두해 두어야 하는 순서나 유의점이 있을까요? 답변 부탁드립니다. 감사합니다.
-
미해결따라하며 배우는 노드, 리액트 시리즈 - 레딧 사이트 만들기(NextJS)(Pages Router)
<npm run dev>시 -61 에러가 나타납니다!
안녕하세요!섹션2 수업내용까지 마치고 npm run dev를 하였는데 오류가 나타납니다 ;-; 커뮤니티에서 -61 에러 관련글을 찾아보니, 데이터베이스 연결 문제를 확인해보라고 하셨는데..;-; 연결 방법을 모르겠습니다..package.json "main"이 index.ts로 되어있어서server.ts로 바꾸었습니다.그랬더니 ;-; 4000번이 열리긴 합니다.그런데 터미널에는 여전히 오류가 함께 나타납니다!!;; 무엇을 확인해보면 될까요 ;-;..?