Coder Social home page Coder Social logo

gorm-oracle's Introduction

GORM Oracle driver

Description

GORM-ORACLE is a GORM driver that does not depend on the Oracle client, Based on github.com/CengSin/oracle , not thoroughly tested and not recommended for production use.

项目集成go-ora驱动,无需安装oracle客户端。

DB Driver

go-ora A pure golang development of Oracle driver, do not need to install Oracle client.

Quick Start

how to install

go get github.com/wdrabbit/gorm-oracle

usage

import (
    "gorm.io/gorm"
    "oracle "github.com/wdrabbit/gorm-oracle"
    "log"
)

//ORM bean
type TestBean struct {
	Id string `gorm:"column:ID;not null;primaryKey;size:36"`
	Field1 string `gorm:"column:FIELD1;size:255"`
	Field2 string `gorm:"column:FIELD2;size:255"`
	State string `gorm:"column:STATE;size:2"`
	CreateAt time.Time `gorm:"column:CREATE_AT"`
}

func main(){

    databaseURL := "oracle://username:password@host:port/db"
    db, err := gorm.Open(oracle.Open(databaseURL),&gorm.Config{})
    if err != nil {
        log.Fatal(err)
    }
    
    //Insert
    datas := []bean.TestBean{
        {"a","a","a","01",time.Now()},
        {"b","a","a","01",time.Now()},
    }
    db = db.Debug().Create(&datas)

    //Update
    db = db.Debug().Where("id=?","a").Model(&bean.TestBean{}).Update("state","02")

    //Delete
    db := db.Where("id = ?","a").Delete(&bean.TestBean{})

    //Select
    var rows []bean.TestBean
    db = db.Debug().Find(&rows)
    
    //do somethings

}

gorm-oracle's People

Contributors

wdrabbit avatar

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.