git clone https://github.com/kgex/bigbbeInstall Postgresql
sudo -u postgres psql\passwordCREATE DATABASE bigbbe;exit\passwordCREATE DATABASE bigbbe;exitsudo apt install virtualenvvirtualenv envsource env/bin/activate
pip install -r requirements.txtpip install -m virtualenvpython -m venv env
./env/Scripts/activateIf you get an UnauthorizedAccess error, then open PowerShell in admin mode and type the following command
set Restriction-Policy Unrestrictedand rerun the above commands and finally
pip install -r requirements.txtnano ~/.bashrcand add the following lines at the end
export SQLALCHEMY_DATABASE_URL="postgresql://postgres:password@localhost/bigbbe"
export SENDGRID_API_KEY="<your api key goes here>"
export SENDER_EMAIL="<your authorized sender email address goes here>"and in your terminal
source ~/.bashrcStep 1:Open your search bar using the Windows key and search for "Edit environment and system variables" and click on the first option
Step 3: In the System variables tab, click on new and you will see two input boxes called Variable name and Variable value
The words on the left hand side of the = go in the Variable name box and the ones on the right hand side go in the Variable value box
SQLALCHEMY_DATABASE_URL = postgresql://postgres:password@localhost/bigbbe
SENDGRID_API_KEY = <your api key goes here>
SENDER_EMAIL = <your authorized sender email address goes here>
If you have successfully completed the database setup as mentioned above, then we can migrate our models into our database using alembic
alembic init migrationsYou should now see a folder called migrations and a file called alembic.ini
postgresql://postgres:password@localhost/bigbbe
You need to replace password with the password you entered changed to using \password.
Keep this string stored somewhere accessible outside the project as this string will be used to connect bigbbe to your local database
import app.models as models
target.metadata = models.Base.metadataStep 4: Migrate your models by opening your terminal inside the root directory of bigbbe and enter the commands
alembic revision --autogenerate -m "msg"
alembic upgrade headNow the database has been setup completely.
To run the app, first the virtual env must be activated
./env/Scripts/activatesource env/bin/activateand when your env has been activated, you can run the app using the following command
uvicorn app.main:app --reloadWhen you make any changes to the models and want to see them reflected on your database, you can use the following commands
alembic revision --autogenerate -m "msg"
alembic upgrade head