Guinsoo
GitHub
  • Welcome to Guinsoo!
  • Guides
    • Introduction
    • Quickstart
    • Features
    • Installation
    • Tutorial
      • Using the Server
      • Clients for Guinsoo
        • NodeJS
        • Go
        • Rust
        • C++
        • Python
        • Java
      • Web UI for Guinsoo
      • The Shell Tool
      • CSV Support
    • Security
    • Performance
    • Advanced
  • Reference
    • Commands
    • Functions
    • Aggregate
    • Window
    • Data Types
    • SQL Grammar
    • System Table
  • Support
    • FAQ
  • Appendix
    • Links
    • Architecture
    • Contribute
    • License
Powered by GitBook
On this page

Was this helpful?

  1. Guides
  2. Tutorial
  3. Clients for Guinsoo

Rust

The database was created as MODE=PostgreSQL.

MySQL or others dialogs can be created.

use postgres::{Client, NoTls, Error};

fn main() -> Result<(), Error> {
    let mut client = Client::connect("sa:sa@localhost:5435/test", NoTls)?;
    
    client.batch_execute("
        CREATE TABLE IF NOT EXISTS author (
            id              SERIAL PRIMARY KEY,
            name            VARCHAR NOT NULL,
            country         VARCHAR NOT NULL
            )
    ")?;

    client.batch_execute("
        CREATE TABLE IF NOT EXISTS book  (
            id              SERIAL PRIMARY KEY,
            title           VARCHAR NOT NULL,
            author_id       INTEGER NOT NULL REFERENCES author
            )
    ")?;

    Ok(())

}
PreviousGoNextC++

Last updated 2 years ago

Was this helpful?