Securely read sql into a pandas dataframe from a remote mysql DB
Project description
Read SQL into a pandas data frame from a remote server
Installation
pip install remote-read-sql
Usage
In this example, remote_read_sql opens an ssh tunnel and connects to the mysql server locally on port 3306. The SQL query is sanitized and passed to pandas read_sql.
After reading the data into the dataframe, the ssh and db connections are closed.
# change to your own paths
ssh_config = Path("~/.my_ssh_config")
my_cnf_path = Path("~/.my.cnf")
db_name = "my_database"
# combine kwargs into a dictionary
opts = {
"ssh_config_path": ssh_config,
"my_cnf_path": my_cnf_path,
"my_cnf_connection_name": "remote_server",
"db_name": db_name,
}
# open ssh, open db, read sql into dataframe, close db, close ssh
df = remote_read_sql("SELECT * FROM subject_glucose", **opts)
# inspect the dataframe
df.head()
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file remote_read_sql-1.1.0.tar.gz.
File metadata
- Download URL: remote_read_sql-1.1.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44eda036d96b2e24cf2fafb408f7833d213b2d20174a5ad52e72569ac895a394
|
|
| MD5 |
5b81e758f4bde9ed98edb171f74cfe26
|
|
| BLAKE2b-256 |
85a34ad11e15454dec1c20ed2161eb0abeea28db6f648c418bf754221135f479
|
File details
Details for the file remote_read_sql-1.1.0-py3-none-any.whl.
File metadata
- Download URL: remote_read_sql-1.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
352eeb03df8b37b7168b8a1623dc2cec3e1e17aaf14b2c3a8bbeff6ecc0e12f1
|
|
| MD5 |
4115ca006683989893a736d911096272
|
|
| BLAKE2b-256 |
c4eb868383fa7f40f18798214c1ca4794c9f63ef3de628e45840cc4d5cbdb191
|