GithubHelp home page GithubHelp logo

Is this project mysql only? about casdoor HOT 3 CLOSED

casdoor avatar casdoor commented on May 22, 2024
Is this project mysql only?

from casdoor.

Comments (3)

hsluoyz avatar hsluoyz commented on May 22, 2024 1

@kuchaguangjie see: https://github.com/casbin/casdoor#config

Casdoor uses XORM to connect to DB, so all DBs supported by XORM can also be used.

XORM supports a lot of DBs including PostgreSQL: https://gitea.com/xorm/xorm#drivers-support

image

from casdoor.

kuchaguangjie avatar kuchaguangjie commented on May 22, 2024

It does support pg, but require some modification to work, since the code include some mysql specific config.

The changes I made to make it work with postgresql:

1. Create db by hand.
2. Edit conf/app.conf

  • dataSourceName
    Change:

    dataSourceName = "user=postgres password=xxxxxx host=127.0.0.1 port=5432 dbname=casdoor sslmode=disable"

3. Edit object/adapter.go

  • In InitAdapter()
    Change:

    adapter = NewAdapter("postgres", beego.AppConfig.String("dataSourceName"))

  • In open()
    Remove:

    if err := a.createDatabase(); err != nil {
    panic(err)
    }

    Change:

    engine, err := xorm.NewEngine(a.driverName, a.dataSourceName)`

4. Edit authz/authz.go

  • In InitAuthz()
    Change:

    a, err := xormadapter.NewAdapter("postgres", beego.AppConfig.String("dataSourceName"), true)

Then it will able to start.


BTW, I think the code could be refactored to support various db without changes. As you mentioned, it use XORM, and the dataSourceName config is for github.com/casbin/xorm-adapter/v2.

from casdoor.

hsluoyz avatar hsluoyz commented on May 22, 2024

@kuchaguangjie thanks!

@kininaru plz modify the code to support both MySQL and PG without any code changes.

from casdoor.

Related Issues (20)

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.