Installing
The Python libraries for DataTables can be installed with npm, or a compatible package manager.
npm installation
pip is a dependency and package manager for Python which can be used to easily manage and install external libraries such as DataTables's Python libraries. Install the DataTables Python libraries using:
pip install datatables_server
Then, in the Python file where you wish to use the libraries, you import them:
from datatables_server import DataTable, Column
Database connection
The next step is to set up the database connection so the libraries can interact with the server, reading and modified data as required. This is done with SQLAlchemy Core. The SQLAlchemy documentation does an excellent job of explaining its own connection options - you essentially just need to create a database connection object and pass that on to the DataTables Python libraries to use.
You will also need a database driver, e.g. pymysql, psycopg2-binary or pyodbc.
A sample configuration might look like:
from sqlalchemy import create_engine
engine = create_engine("postgresql+psycopg2://user:pass@localhost/mydb")
This is typically done in a function in its own file so you can import that file from any other, allowing the database connection to be configured from a single location.
Sources
If you are interested in using the Python libraries directly from its git repository, you can find it on Github. The DataTables Python source is released under the MIT license.
Next steps
With the server-side package installed, imported into your file and a database connection, we can move on to working with the libraries!