Les's to use a unique ORM to manage the persistence in one project.
Project description
full_alchemyst
Let's you to use both SqlAlchemyst and MongoAlchemyst libraries Les's to use a unique ORM to manage the persistence in one project.
How to Use?
You need to configurate a dictionary with the next parameters: db_config = { "type":"mongo", "host": "localhost", "port":27017, "user":"", "database":"google", "password":"", "SQLALCHEMY_TRACK_MODIFICATIONS":True }
- *** type: *** mongo | mysql
- *** host: *** Host where the database is
- *** port: *** Port of engine runs
- *** user: *** User
- *** databse: *** Name of database
- *** password: *** Password
How you see, you can to specify other attributes of the ORM, like "SQLALCHEMY_TRACK_MODIFICATIONS".
After to set the configuration that you want to use, you have to create a FullAlchemyst instance:
app = Flask(__name__)
fullAlchemyst= FullAlchemyst(app,db_config)
Obviusly, What is a ORM without models? Create one:
class task(fullAlchemyst.Entity):
id = define(fullAlchemyst.db, {"name":"id","type":"int","primary_key":True})
nombre = define(fullAlchemyst.db, {"name":"nombre","type":"str"})
Steps:
- First, you need to extend you model of fullAlchemyst.Entity
- Define your attributes. In this step, remember to use the "define" function. We see this later
"define" function
This function is used to configurate you model depending what type of database you use.
This function, receives a dict, and its structure is the next:
- type : int | str o another inside de buildins of python.
- primary_key : If you attribute is a primary key.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for full_alchemyst-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d3fa8e31a84a42814251f0938547db13190101be74a0a09d853fadf29eb7363 |
|
MD5 | bdb8e351d4b4c1aece14f7b2ad3c07f5 |
|
BLAKE2b-256 | 8a83affa7723a927d7c7615f34e5e694d7841eaf9cc440c662057e0c2c3c04f1 |