xxxxxxxxxx
(Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py -UseBasicParsing).Content | python -
xxxxxxxxxx
# install
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3 -
# setup
poetry new <name> # new project
poetry init # existing project
poetry install
# requirements.txt
poetry add `cat requirements.txt`
poetry export --output requirements.txt
# venv
poetry run python your_script.py # single script
poetry shell # venv sub shell
# dependencies
poetry show --tree
poetry add <name>
poetry remove <name>
poetry update
# build and publish
poetry build
poetry config http-basic.pypi username password
poetry publish
xxxxxxxxxx
# Install Poetry Python using this command the others are deprecated
curl -sSL https://install.python-poetry.org/ | python3
xxxxxxxxxx
(Invoke-WebRequest -Uri https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py -UseBasicParsing).Content | python -
xxxxxxxxxx
from flask import Flask
from flask_mysqldb import MySQL
app = Flask(__name__)
# Required
app.config["MYSQL_USER"] = "user"
app.config["MYSQL_PASSWORD"] = "password"
app.config["MYSQL_DB"] = "database"
# Extra configs, optional:
app.config["MYSQL_CURSORCLASS"] = "DictCursor"
app.config["MYSQL_CUSTOM_OPTIONS"] = {"ssl": {"ca": "/path/to/ca-file"}} # https://mysqlclient.readthedocs.io/user_guide.html#functions-and-attributes
mysql = MySQL(app)
@app.route("/")
def users():
cur = mysql.connection.cursor()
cur.execute("""SELECT user, host FROM mysql.user""")
rv = cur.fetchall()
return str(rv)
if __name__ == "__main__":
app.run(debug=True)
xxxxxxxxxx
$ poetry build
Building poetry (1.0.0)
- Building sdist
- Built poetry-1.0.0.tar.gz
- Building wheel
- Built poetry-1.0.0-py2.py3-none-any.whl fvrvevevvvev
xxxxxxxxxx
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3 -