
fbird_db_info를 사용하여 SQLite 데이터베이스에 접속하는 방법은 다음과 같습니다.
1. fbird_db_info를 import합니다.
#hostingforum.kr
python
import fbird_db_info
2. SQLite 데이터베이스에 접속할 수 있는 정보를 입력합니다.
#hostingforum.kr
python
db_info = fbird_db_info.SQLiteDBInfo(
host='localhost',
port=3306,
user='username',
password='password',
db_name='database_name'
)
3. SQLite 데이터베이스에 접속합니다.
#hostingforum.kr
python
db = db_info.connect()
fbird_db_info를 사용하여 SQLite 데이터베이스에 데이터를 저장하는 방법은 다음과 같습니다.
1. 데이터를 저장할 테이블이 존재해야 합니다.
#hostingforum.kr
python
cursor = db.cursor()
cursor.execute('''
CREATE TABLE IF NOT EXISTS table_name (
column1 TEXT,
column2 TEXT
)
''')
2. 데이터를 저장합니다.
#hostingforum.kr
python
cursor.execute('''
INSERT INTO table_name (column1, column2)
VALUES ('value1', 'value2')
''')
db.commit()
fbird_db_info를 사용하여 SQLite 데이터베이스의 데이터를 조회하는 방법은 다음과 같습니다.
1. 데이터를 조회할 테이블이 존재해야 합니다.
#hostingforum.kr
python
cursor = db.cursor()
cursor.execute('''
SELECT * FROM table_name
''')
rows = cursor.fetchall()
2. 조회한 데이터를 출력합니다.
#hostingforum.kr
python
for row in rows:
print(row)
fbird_db_info를 사용하여 SQLite 데이터베이스와의 연결을 끊는 방법은 다음과 같습니다.
1. 데이터베이스 커넥션을 닫습니다.
#hostingforum.kr
python
db.close()
2. 데이터베이스 커넥션을 닫은 후, 데이터베이스 객체를 삭제합니다.
#hostingforum.kr
python
del db
2025-03-09 16:31