Giter Club home page Giter Club logo

tauri-plugin-sql's Introduction

Tauri Plugin SQL

Test

This plugin provides a "classical" Tauri Plugin Interface to SQL databases through sqlx. It supports the sqlite, mysql and postgres drivers, enabled through a Cargo feature.

Architecture

This repo shape might appear to be strange, but it is really just a hybrid Rust / Typescript project that recommends a specific type of consumption, namely using GIT as the secure distribution mechanism, and referencing specific unforgeable git hashes. Of course, it can also be consumed via Cargo and NPM.

/src

Rust source code that contains the plugin definition and sqlx features.

/webview-src

Typescript source for the /webview-dist folder that provides an API to interface with the rust code.

/webview-dist

Tree-shakeable transpiled JS to be consumed in a Tauri application.

/bindings

Forthcoming tauri bindings to other programming languages, like DENO.

Installation

There are three general methods of installation that we can recommend.

  1. Pull sources directly from Github using git tags / revision hashes (most secure, good for developement, shown below)
  2. Git submodule install this repo in your tauri project and then use file protocol to ingest the source
  3. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)

For more details and usage see the Todo app. Please note, below in the dependencies you can also lock to a revision/tag in both the Cargo.toml and package.json

RUST

src-tauri/Cargo.toml

[dependencies.tauri-plugin-sql]
git = "https://github.com/tauri-apps/tauri-plugin-sql"
tag = "v0.1.0"
features = ["sqlite"] # or "postgres", or "mysql"
#branch = "main"

Use in src-tauri/src/main.rs:

use tauri_plugin_sql::TauriSql;

fn main() {
    tauri::Builder::default()
        .plugin(TauriSql::default())
        .build()
        .run();
}

WEBVIEW

Install from a tagged release

npm install github:tauri-apps/tauri-plugin-sql#v0.1.0
# or
yarn add github:tauri-apps/tauri-plugin-sql#v0.1.0

Install from a commit

npm install github:tauri-apps/tauri-plugin-sql#488558717b77d8a2bcb37acfd2eca9658aeadc8e
# or
yarn add github:tauri-apps/tauri-plugin-sql#488558717b77d8a2bcb37acfd2eca9658aeadc8e

package.json

  "dependencies": {
    "tauri-plugin-sql-api": "github:tauri-apps/tauri-plugin-sql#v0.1.0",

Use within your JS/TS:

import Database from 'tauri-plugin-sql-api'

// sqlite. The path is relative to `tauri::api::path::BaseDirectory::App`.
const db = await Database.load('sqlite:test.db')
// mysql
const db = await Database.load('mysql://user:pass@host/database')
// postgres
const db = await Database.load('postgres://postgres:password@localhost/test')

await db.execute('INSERT INTO ...')

License

MIT / Apache-2.0

tauri-plugin-sql's People

Contributors

lucasfernog avatar renovate-bot avatar yankeeinlondon avatar fabianlars avatar jonaskruckenberg avatar hawk93 avatar tech-s1 avatar nothingismagick avatar

Forkers

archiyopp

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.