Spawn a MySQL instance with a test database

This commit is contained in:
coolneng 2020-06-21 15:58:43 +02:00
parent 78b4dd3827
commit deda3b51b5
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
1 changed files with 29 additions and 19 deletions

View File

@ -1,28 +1,38 @@
{ pkgs ? import <nixpkgs> { } }: { pkgs ? import <nixpkgs> { } }:
with pkgs.python37Packages; with pkgs;
pkgs.mkShell { mkShell {
buildInputs = [ buildInputs = [
# Dependencies # Dependencies
fastapi python38Packages.fastapi
uvicorn python38Packages.uvicorn
pydantic python38Packages.pydantic
email_validator python38Packages.email_validator
sqlalchemy python38Packages.sqlalchemy
pymysql python38Packages.pymysql
databases python38Packages.databases
aiomysql python38Packages.aiomysql
alembic python38Packages.alembic
pytest python38Packages.pytest
twilio python38Packages.twilio
mysql57
# Development tools # Development tools
black python38Packages.black
isort python38Packages.isort
pyflakes python38Packages.pyflakes
python-language-server python-language-server
pyls-black
pyls-isort
pyls-mypy
]; ];
shellHook = ''
pkill mysql
rm -rf .mysql && mkdir .mysql
mysqld --datadir="$(pwd)/.mysql" --socket="$(pwd)/.mysql/mysql.sock" --initialize-insecure
mysqld --datadir="$(pwd)/.mysql" --socket="$(pwd)/.mysql/mysql.sock" --skip-networking & sleep 1
mysql --socket="$(pwd)/.mysql/mysql.sock" -u root < $(pwd)/assets/test_db.sql
alias mysql='mysql --socket="$(pwd)/.mysql/mysql.sock" -u root'
'';
} }