搜尋套件、儲存庫與 APP 分類

套件詳情v2.0.0

sql_conn

使用 JDBC 和安全連接池的通用生產就緒 Flutter SQL 連接器。

Android
近 30 天下載
137
喜歡數
52
Pub 分數
150

安裝套件

flutter pub add sql_conn

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

sql_conn 是一個生產就緒的 Flutter SQL 連接器,專為使用 JDBC 的安全高效資料庫互動而設計。它提供連接池以優化效能並確保在高負載環境中的可靠性。從安全性出發建構,支援加密通訊與跨 Android 平台的連接池。適合需要強大後端資料庫整合且延遲極低的應用程式。該套件簡化 SQL 操作,同時維持可擴展性與執行緒安全性。

適用情境

  • 將Flutter應用連接到遠端資料庫
  • 處理高流量資料庫查詢
  • 在生產環境中保護資料庫連接
  • 啟用持久連接池
  • 與現有 JDBC 相容資料庫整合
  • 支援僅 Android 資料庫部署

主要特色

  • 基於 JDBC 的連接
  • 安全連接池
  • 生產級穩定性
  • Android 平台支援
  • 加密資料傳輸
  • 執行緒安全作業

適合對象

  • 企業級 Flutter 應用
  • 高流量的資料庫支援的應用程式
  • 需要安全資料庫存取的應用程式
  • 使用 JDBC 相容資料庫的開發人員
  • 注重連接效率的團隊
  • 面向Android的資料庫整合

使用建議

  • 僅限 Android 平台
  • 需要 JDBC 驅動程式相容性
  • 需要正確的SSL設定
  • 可能需要為複雜架構進行額外設定
  • 不適用於 iOS 或網頁
  • 依賴外部JDBC基礎設施

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

sql_conn

sql_conn is a production-ready Flutter plugin that allows Android applications to connect directly to SQL SERVER databases using JDBC.

It provides a clean, type-safe, null-safe Dart API powered by Pigeon, and a high-performance Android backend.

This plugin is designed for LAN / internal network / enterprise / industrial use-cases where direct database connectivity from a mobile device is required.


✨ Features

  • Android-only direct SQL connectivity
  • Database support:
    • Microsoft SQL Server
  • Prepared statements (parameterized queries)
  • Stored procedure execution
  • SQL script / batch execution
  • Fully null-safe Dart API
  • Type-safe Flutter ↔ Android bridge using Pigeon

📱 Platform Support

Platform Support
Android ✅ Yes
iOS 🚧 Under construction
Web 💭 Planning
Windows 🚫 No
MacOs 🚫 No

Direct database connections from mobile apps should only be used in trusted or internal networks.


🚀 Installation

Add to pubspec.yaml:

dependencies:
  sql_conn: ^2.0.0

⚙️ Basic Usage

Connect to a database
await SqlConn.connect(
  connectionId: "mainDB",
  host: "192.168.1.10",
  port: 1433,
  database: "MyDatabase",
  username: "admin",
  password: "Password@123",
);
Read data
final rows = await SqlConn.read(
  "mainDB",
  "SELECT * FROM users WHERE role = ?",
  params: ["admin"],
);

print(rows);
Write / Update / Delete
final count = await SqlConn.write(
  "mainDB",
  "UPDATE users SET active = ? WHERE id = ?",
  params: [true, 101],
);

print("Rows affected: $count");
Call Stored Procedure
final result = await SqlConn.callProcedure(
  "mainDB",
  "sp_generate_report",
  params: [2026, "JAN"],
);
Execute SQL Script
await SqlConn.executeScript(
  "mainDB",
  """
  CREATE TABLE logs(id INT, message VARCHAR(255));
  CREATE INDEX idx_logs ON logs(id);
  """,
);
Disconnect
await SqlConn.disconnect("mainDB");
🧩 Multiple Connections
await SqlConn.connect(connectionId: "db1", dbType: DatabaseType.sqlServer, ...);
await SqlConn.connect(connectionId: "db2", dbType: DatabaseType.postgres, ...);

final a = await SqlConn.read("db1", "SELECT * FROM table1");
final b = await SqlConn.read("db2", "SELECT * FROM table2");
🔧 Custom JDBC URL
await SqlConn.connect(
  connectionId: "legacy",
  host: "",
  port: 0,
  database: "",
  username: "sysdba",
  password: "masterkey",
  customJdbcUrl: "jdbc:firebirdsql://192.168.1.9/employee",
);

🧠 State Management

sql_conn is a stateless service API. You can integrate it with any state manager:

  • Provider
  • Riverpod
  • Bloc
  • GetX
  • Service Locators
  • Connection lifecycle is fully controlled by your app.

⚡ Performance

  • Prepared statement reuse
  • Non-blocking platform channel
  • Minimal memory overhead

🔐 Security

  • Prepared statements prevent SQL injection
  • No credential logging

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。