Skip to main content

Autogenerate Flask API for dbhydra ORM DB structure

Project description

flask_dbhydra

Autogenerate Flask API for dbhydra ORM DB structure. Allows to easily define with a simple dictionary what type of REST API operations should be allowed for tables in database + it is customizable.

flask_dbhydra_dict={'users':'read','items':'read'}

Installation

Use the package manager pip to install flask_dbhydra.

pip install flask_dbhydra

Usage

from flask import Flask
from flask_mysqldb import MySQL 
from flask_cors import CORS
import dbhydra.dbhydra_core as dm
import flask_dbhydra.flask_dbhydra_core as flaskhydra

app = Flask(__name__)
db1=dm.Mysqldb("config.ini") #Need to specify connection parameters to MySQL DB
db1.close_connection()

app.config['MYSQL_USER'] = db1.DB_USERNAME
app.config['MYSQL_PASSWORD'] = db1.DB_PASSWORD
app.config['MYSQL_DB'] = db1.DB_DATABASE
app.config['MYSQL_CURSORCLASS'] = 'DictCursor'
app.config['JWT_SECRET_KEY'] = 'secret'

mysql = MySQL(app)
CORS(app)

TABLE_NAME="users"

item_name="item"
column1_name="column1"
column2_name="column2"

flask_dbhydra_dict={'users':'read','items':'read'}
flaskhydra.initialize_api(app,flask_dbhydra_dict,["name","data","item_name"],mysql,column1_name=column1_name)
    
app.run(debug=True)

obrazek

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask_dbhydra-0.1.7.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

flask_dbhydra-0.1.7-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file flask_dbhydra-0.1.7.tar.gz.

File metadata

  • Download URL: flask_dbhydra-0.1.7.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for flask_dbhydra-0.1.7.tar.gz
Algorithm Hash digest
SHA256 395d36a574e9130bec98409e5dfb18d93e043e443fccdf14c188ce66f990cb3e
MD5 2d3f77be2633aacde03acce43afe2b20
BLAKE2b-256 17031fe16c89ce5fb8b56c293c8521dff06c2d91e240bd285baf5f9c0c925445

See more details on using hashes here.

File details

Details for the file flask_dbhydra-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for flask_dbhydra-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 fd4fb87dfbe81759c5dd024f0a31aa5ad248b2affd963d9ef3dbf18f4a1c92e7
MD5 d4ae0a1c28f27d1d87fb173dd9d3667a
BLAKE2b-256 1b06ae35135b509cc32fa49caf31a49d801e7542c27c56e51a3abb6a6c87db1e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page