반응형

백엔드 Back-end/데이터베이스 Database 24

파이썬에서 sqlite3 예제 코드 CREATE, INSERT, SELECT, DELETE, UPDATE

간단한 sqlite3 예제 코드다. CREATE conn = sqlite3.connect('student.sqlite') cursor = conn.cursor() cursor.execute("CREATE TABLE student (id INTEGER primary key autoincrement, name char(32), class char(4))") cursor.close() conn.close() INSERT conn = sqlite3.connect('student.sqlite') cursor = conn.cursor() cursor.execute("INSERT INTO student (name, class) VALUES (?, ?)", ['홍길동', '1-1']) id = cursor.lastro..

You have an error in your SQL syntax; 에러

MariaDB에 데이터를 입력하려고 하는데 에러가 났다. 에러 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near \'order 원인은? 칼럼, 필드명에 order란 예약어를 썼기 때문이다. 힌트는 use near 다음에 나오는 단어에 있었다. MariaDB Reserved Words: 마리아DB 예약어 MySQL Resverd Words: MySQL 예약어 해결책 칼럼명에 쓴 order를 다른 것으로 바꾸었다.

MySQL 데이터베이스명, 테이블명, 컬럼명은 어떻게 지어야 할까?

database naming conventions라고 검색해 본다. convention은 관습이란 뜻이다. 다른 사람들은 어떻게 이름을 만들어서 쓰고 있을까? dev.mysql.com Write SQL statements in the style of the MySQL Reference Manual SQL keywords and reserved words: uppercase Identifiers (table names, column names, etc.): lowercase (출처: dev.mysql.com) SQL 키워드 예약어는 대문자로 작성 테이블명, 컬럼명 등은 소문자로. SQL Style Guide by Simon Holywell 여기 내용이 좋은 거 같다. (출처: www.sqlstyle.gui..

반응형