Code Monkey home page Code Monkey logo

note-rocket's Introduction

📔 note-rocket

📖 语言

简体中文 | English

⌛ 开始

安装 diesel_cli

  • 安装 diesel_cli (只安装 SQLite 数据库的 diesel_cli)
cargo install diesel_cli --no-default-features --features sqlite-bundled

Windows 编译 sqlite3.lib

  • Visual Studio 安装目录下找到类似以下路径的目录
D:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64
  • 复制 x64 文件夹到任意目录下
  • SQLite 安装目录下的 sqlite3.def 文件复制到新的 x64 文件夹中
  • x64 目录下执行以下命令
    • 编译 sqlite3.lib
lib /DEF:sqlite3.def /MACHINE:X64
  • 将生成的 sqlite3.lib 文件和 sqlite3.exp 文件复制到 SQLite 安装目录下
  • SQLite 安装目录下,使用 PowerShell 执行以下命令
    • sqlite3.dll 文件和 sqlite3.lib 文件复制到 .rustup 目录下
    • 根据使用的 Rust 工具链版本,复制到 stablenightly 对应的目录下
# use rust toolchain stable version
cp sqlite3.lib c:\Users\11441\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\sqlite3.lib
cp sqlite3.dll c:\Users\11441\.rustup\toolchains\stable-x86_64-pc-windows-msvc\bin\sqlite3.dll

# use rust toolchain nightly version
cp sqlite3.lib c:\Users\11441\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\sqlite3.lib
cp sqlite3.dll c:\Users\11441\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\bin\sqlite3.dll

生成 SQLite 数据库文件

  • 在项目根目录下执行以下命令
  • 使用 diesel 创建项目对应的 SQLite 数据库文件
diesel setup --database-url=database.sqlite
  • 创建存放 diesel SQL 的文件夹
diesel migration generate create_card
  • up.sql 中写创建表的操作
CREATE TABLE note_card
(
    id          BIGINT PRIMARY KEY NOT NULL,
    title       VARCHAR            NOT NULL,
    content     VARCHAR            NOT NULL,
    tip         VARCHAR            NOT NULL,
    extra       VARCHAR            NOT NULL,
    create_time TIMESTAMP          NOT NULL
)
  • down.sql 中写删除表的操作
DROP TABLE note_card
  • 创建 schema.rs 文件
diesel migration run --database-url=database.sqlite

运行

cargo run

调试构建

cargo build

发布构建

cargo build --release

📜 开源协议

MIT License Copyright (c) 2022 周博义

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.