Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add lua-mysql install example #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,19 @@ jobs:
run: |
sudo /etc/init.d/mysql start
mysql -e 'CREATE DATABASE ${{ env.MYSQL_DB }};' -u${{ env.MYSQL_USER }} -p${{ env.MYSQL_PASSWORD }}
luarocks install casbin
luarocks install https://raw.githubusercontent.com/casbin/lua-casbin/master/casbin-1.41.1-1.rockspec
sudo apt install sqlite3 libsqlite3-dev lua-sql-mysql libpq-dev
luarocks install luasql-mysql MYSQL_INCDIR=/usr/include/mysql/
luarocks install luasql-postgres PGSQL_INCDIR=/usr/include/postgresql/
luarocks install luasql-sqlite3
# install luasql driver
sudo git clone https://github.com/lunarmodules/luasql.git
cd luasql/rockspec
sudo cp ./luasql-mysql-2.6.0-1.rockspec ../luasql-mysql-2.6.0-1.rockspec
sudo cp ./luasql-postgres-2.6.0-1.rockspec ../luasql-postgres-2.6.0-1.rockspec
sudo cp ./luasql-sqlite3-2.6.0-1.rockspec ../luasql-sqlite3-2.6.0-1.rockspec
cd ..
luarocks make luasql-mysql-2.6.0-1.rockspec MYSQL_INCDIR=/usr/include/mysql/
luarocks make luasql-postgres-2.6.0-1.rockspec PGSQL_INCDIR=/usr/include/postgresql/
luarocks make luasql-sqlite3-2.6.0-1.rockspec
cd ..
luarocks install busted
luarocks install busted-htest
luarocks install luacov-coveralls
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ First, install the corresponding driver of LuaSQL from LuaRocks based on the dat
- For PostgreSQL, install luasql-postgres.
- For SQLite3, install luasql-sqlite3.

Take installing luasql-mysql for example, others are similar:
- If there is no mysql locally, please install it locally.
- Run `whereis mysql` to find your mysql path, then cd into th path to find include path and lib path.
```shell
[root@master ~]# whereis mysql
mysql: /usr/bin/mysql /usr/local/mysql
```
- Use mysql include path and lib path to install luasql-mysql. Run `luarocks install luasql-mysql MYSQL_INCDIR=/usr/local/mysql/include MYSQL_LIBDIR=/usr/local/mysql/lib`

Then install the casbin-adapter from LuaRocks by
```bash
sudo luarocks install https://raw.githubusercontent.com/casbin-lua/luasql-adapter/master/casbin-adapter-1.0.0-1.rockspec
Expand Down