▣ 설계자가 자신만의 데이터베이스를 활용하면 이점은 무엇일까?
(What are the benefits of designers utilizing their own databases?)
설계자는 프로젝트에 사용된 자재, 부품, 도면, 설계 기준 등의 정보를 데이터베이스에 체계적으로 저장하고 관리할 수 있습니다. 이렇게 하면 필요한 정보를 빠르게 검색하고 재사용할 수 있어, 설계 시간을 크게 단축할 수 있습니다. 예를 들어, 이전에 설계한 부품을 찾아 새로운 프로젝트에 바로 적용하거나, 어떤 자재가 특정 조건에 맞는지 쉽게 확인할 수 있습니다.
Designers can systematically store and manage information such as materials, parts, drawings, and design criteria used in a project in a database. This allows for quick retrieval and reuse of necessary information, significantly reducing design time. For example, they can find previously designed parts and immediately apply them to new projects, or easily determine which materials meet specific requirements.
엑셀 VBA로 자신만의 PorsgreSQL에 자신만의 테이블을 만들어 봅니다. PorsgreSQL과 Excel 대한 기본지식이 있다면, 누구나 쉽게 AI를 활용하여 자시만의 코드를 만들수 있습니다.
Create your own table in your own PorsgreSQL with Excel VBA. Anyone with basic knowledge of Python, SQL, and Excel can easily create their own code using AI.
▣ Table creation screen

▷ Code
Option Explicit
Sub CreatePostgreSQLTable()
Dim conn As Object
Dim rs As Object
Dim sql As String
Dim connectionString As String
Dim ws As Worksheet
Dim databaseName As String
Dim schemaName As String
Dim tableName As String
' 워크시트 설정
Set ws = ThisWorkbook.Sheets("maketable") ' 사용 중인 시트를 지정하세요
' 셀에서 동적 값 가져오기 (d6, d7, d8에 해당)
databaseName = ws.Range("D6").Value ' Database Name
schemaName = ws.Range("D7").Value ' Schemas
tableName = ws.Range("D8").Value ' Tables (Creo_Name_Table)
' PostgreSQL ODBC 연결 문자열
connectionString = "Driver={PostgreSQL Unicode(x64)};" & _
"Server=localhost;" & _
"Port=5432;" & _
"Database=" & databaseName & ";" & _
"Uid=designer;" & _
"Pwd=7777;" ' 실제 비밀번호로 대체하세요
' ADO 연결 객체 생성
Set conn = CreateObject("ADODB.Connection")
' 연결 시도
On Error GoTo ErrHandler
conn.Open connectionString
' 시퀀스 생성 SQL 문
sql = "CREATE SEQUENCE IF NOT EXISTS " & schemaName & ".user_id_seq START WITH 1 INCREMENT BY 1;"
conn.Execute sql
' 테이블 생성 SQL 문 (USER_ID에 자동 증가 패턴 적용)
sql = "CREATE TABLE " & schemaName & "." & tableName & " (" & _
"USER_ID VARCHAR(20) PRIMARY KEY DEFAULT 'ABC-' || nextval('" & schemaName & ".user_id_seq')," & _
"CREO_FILE_NAME VARCHAR(40) NOT NULL);"
' SQL 실행
conn.Execute sql
MsgBox "테이블 '" & schemaName & "." & tableName & "'이(가) 성공적으로 생성되었습니다!", vbInformation
' 연결 종료
conn.Close
Set conn = Nothing
Exit Sub
ErrHandler:
MsgBox "오류 발생: " & Err.Description, vbCritical
If conn.State <> 0 Then conn.Close
Set conn = Nothing
End Sub
USER_ID를 "PRIMARY KEY"로 정의 했으며, "CREO_FILE_NAME"를 입력하면, 자동적으로 "ABC-1", "ABC-2", "ABC-3" . .. 형식으로 자동 증가 됩니다.
I defined USER_ID as "PRIMARY KEY", and when I enter "CREO_FILE_NAME", it automatically increases in the format "ABC-1", "ABC-2", "ABC-3" . . .
Creo 또는 Solidwork의 엑셀 VBA API와 데이터 베이스를 활용한다면. 그동안 생각하지 못했던 정보를 얻을수 있습니다.
AI가 이것을 가능하게 합니다. AI를 적극 활용 하십시요.
By leveraging Creo or Solidwork's Excel VBA API and databases, you can gain insights you never thought possible. AI makes this possible. Take advantage of AI.
PostgreSQL 테이블 생성
테이블 생성 테이블은 데이터를 담는 그릇으로써 반드시 생성해야만 데이터를 저장 할 수 있습니다. 테이블 생성시 컬럼의 제약 조건 제약조건명 설명 NOT NULL 해당 제약 조건이 있는 컬럼은 NULL
dog-developers.tistory.com
by korealionkk@gmail.com

'업무 자동화 > PostgreSQL' 카테고리의 다른 글
| PostgreSQL Study] 데이터 베이스 키(Key) (2) | 2025.08.04 |
|---|---|
| 관계형 데이터 베이스란? (3) | 2025.08.04 |
| PostgreSQL 공부하기 -사이트 (0) | 2025.08.01 |
| PostgreSQL] VBA로 데이터 베이스 읽기 쓰기 #4 (0) | 2025.08.01 |
| PostgreSQL] VBA로 데이터 베이스 읽기 쓰기 #3 (0) | 2025.07.30 |