패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.22.0

mysql1

MySQL 및 MariaDB 데이터베이스에 연결하고 쿼리를 실행하기 위한 라이브러리입니다.

AndroidiOSmacOSWindowsLinux
30일 다운로드
1.2만
좋아요
493
Pub 점수
160

패키지 설치

flutter pub add mysql1

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

mysql1 패키지는 Flutter 애플리케이션에서 MySQL 및 MariaDB 데이터베이스에 연결하고 쿼리를 실행할 수 있도록 해주는 Dart 라이브러리입니다. SQL 문을 실행하고, 트랜잭션을 처리하며, 데이터베이스 연결을 효율적으로 관리하기 위한 간단한 API를 제공합니다. 크로스플랫폼 사용을 위해 설계되어 Android, iOS, macOS, Windows, Linux를 지원하며, 모바일 및 데스크톱 앱의 백엔드 통합에 적합합니다. 이 라이브러리는 활발히 유지보수되며, 네이티브 MySQL 프로토콜 위에 구축되어 있어 신뢰성 있는 성능과 최신 데이터베이스 기능과의 호환성을 보장합니다.

사용 사례

  • Flutter 앱을 MySQL/MariaDB 데이터베이스에 연결하는 방법
  • 실시간으로 동적 SQL 쿼리 실행하기
  • 데이터베이스 트랜잭션 관리
  • 모바일 앱을 위한 백엔드 서비스 구축
  • 기존의 MySQL 기반 시스템과의 통합

주요 기능

  • 크로스 플랫폼 지원 (Android, iOS, macOS, Windows, Linux)
  • MySQL 및 MariaDB 지원
  • 효율적인 연결 풀링
  • 트랜잭션 관리
  • 비동기/대기 호환 API

적합한 대상

  • 데이터베이스 액세스가 필요한 모바일 및 데스크톱 앱
  • MySQL/MariaDB를 사용하는 백엔드 서비스
  • 풀스택 플러터 애플리케이션을 개발하는 개발자
  • 기존 MySQL 인프라스트럭처와 통합된 팀

고려 사항

  • 데이터베이스 서버에 대한 네트워크 액세스가 필요합니다
  • 연결 문제에 대한 적절한 오류 처리가 필요합니다
  • SSL/TLS를 위해 추가 구성이 필요할 수 있습니다
  • 로컬 파일 기반 데이터베이스에 적합하지 않습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

mysql1

A MySQL driver for the Dart programming language. Works on Flutter and on the server.

This library aims to provide an easy to use interface to MySQL. mysql1 originated as a fork of the SQLJocky driver.

Usage

Connect to the database

var settings = new ConnectionSettings(
  host: 'localhost', 
  port: 3306,
  user: 'bob',
  password: 'wibble',
  db: 'mydb'
);
var conn = await MySqlConnection.connect(settings);

Execute a query with parameters:

var userId = 1;
var results = await conn.query('select name, email from users where id = ?', [userId]);

Use the results:

for (var row in results) {
  print('Name: ${row[0]}, email: ${row[1]}');
});

Insert some data

var result = await conn.query('insert into users (name, email, age) values (?, ?, ?)', ['Bob', 'bob@bob.com', 25]);

An insert query's results will be empty, but will have an id if there was an auto-increment column in the table:

print("New user's id: ${result.insertId}");

Execute a query with multiple sets of parameters:

var results = await query.queryMulti(
    'insert into users (name, email, age) values (?, ?, ?)',
    [['Bob', 'bob@bob.com', 25],
    ['Bill', 'bill@bill.com', 26],
    ['Joe', 'joe@joe.com', 37]]);

Update some data:

await conn.query(
    'update users set age=? where name=?',
    [26, 'Bob']);

Parameters

Parameters are bound client side. The values are escaped, written into the statement as literals, and the result is sent as a single query - there is no server side prepare/execute/close. This is what mysqlclient does, and so how most MySQL deployments already send their statements.

The reason to do it this way is query planning. A bound value is opaque to the optimizer, so if the leading column of an index is a parameter it takes ref access on that column and never builds a range, and a keyset page can degrade into a scan.

? placeholders inside string literals and inside ` quoted identifiers are left alone. null, int, double, bool, String and DateTime (UTC only, second precision) can be bound, as can Blob and List<int> - both are written as hex literals, so bytes which are not valid in the connection charset survive. Anything else is bound as its toString().

Escaping assumes the connection charset is utf8 or utf8mb4, and that the server is not in NO_BACKSLASH_ESCAPES mode. Both hold for a connection opened by this driver with default settings.

Flutter Web

This package opens a socket to the database. The web platform does not support sockets and so this package does not work on flutter web.

카테고리

의존성

의존성 목록 4 개

소스 저장소

이 패키지를 사용하는 프로젝트