-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Big refactoring. Made databases into classes. Changed unit tests to reflect the same. Added more examples on README * fix a mistake on readme
- Loading branch information
1 parent
6fb39fb
commit 51d1c71
Showing
15 changed files
with
503 additions
and
461 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,18 +12,6 @@ | |
- **Formatted Output**: View data in a clean, formatted table or JSON format. | ||
- **Pagination**: Efficiently handle large datasets by viewing data in manageable chunks. | ||
|
||
## 🎬 peepDB in Action | ||
|
||
Here's a quick demonstration of peepDB: | ||
|
||
![peepDB Demo](images/demo.gif) | ||
|
||
## 🖼️ peepDB stills | ||
|
||
![peepDB example 2](images/peepdb_example2.png) | ||
|
||
> **Note:** The above image reflect the commands used in the official release (v0.1.3) | ||
## 📦 Installation | ||
|
||
You can install peepDB directly from PyPI: | ||
|
@@ -32,43 +20,39 @@ You can install peepDB directly from PyPI: | |
pip install peepdb | ||
``` | ||
|
||
**Requirements:** | ||
- Python 3.6 or higher | ||
- pip (Python package installer) | ||
|
||
> **Note:** If peepdb gives an error like "The term 'peepdb' is not recognized as the name of a cmdlet" remember to add the Python Scripts folder to your PATH in Windows. | ||
## System Dependencies | ||
## 🛠️ Usage | ||
|
||
Before installing peepdb, ensure you have the following system dependencies: | ||
peepDB uses a command-based structure for easier and more intuitive use. Here are the main commands with examples: | ||
|
||
```bash | ||
sudo apt-get update | ||
sudo apt-get install libmariadb3 libmariadb-dev | ||
``` | ||
### 1. Save Your Database Connection Details | ||
|
||
Verify the installation by running: | ||
```bash | ||
peepdb --version | ||
peepdb save <connection_name> --db-type [mysql/postgres/mariadb] --host <host> --user <user> --password <password> --database <database> | ||
``` | ||
|
||
## 🛠️ Usage | ||
|
||
peepDB uses a command-based structure for easier and more intuitive use. Here are the main commands: | ||
|
||
### 1. Save Your Database Connection Details | ||
**Important Note on Password Handling:** | ||
The password is required as a command-line argument. While this is convenient for scripting, it's important to note that this method can be insecure as the password may be visible in your command history or to other users who can view your screen or process list. | ||
|
||
Example: | ||
```bash | ||
peepdb save <connection_name> --db-type [mysql/postgres/mariadb] --host <host> --user <user> --database <database> | ||
peepdb save myapp_db --db-type mysql --host localhost --user root --password my_secure_password --database myapp | ||
``` | ||
You'll be prompted securely for the password. | ||
|
||
For improved security, consider using environment variables or a configuration file to store sensitive information like passwords. | ||
|
||
### 2. List Saved Connections | ||
|
||
```bash | ||
peepdb list | ||
``` | ||
|
||
Example output: | ||
``` | ||
Saved connections: | ||
- myapp_db (mysql) | ||
- analytics_db (postgres) | ||
``` | ||
|
||
### 3. View Tables | ||
|
||
View all tables: | ||
|
@@ -81,20 +65,62 @@ View a specific table: | |
peepdb view <connection_name> --table <table_name> | ||
``` | ||
|
||
Example: | ||
```bash | ||
peepdb view myapp_db --table users | ||
``` | ||
|
||
Output: | ||
``` | ||
Table: users | ||
+----+----------+----------------------+ | ||
| id | username | email | | ||
+====+==========+======================+ | ||
| 1 | johndoe | [email protected] | | ||
| 2 | janedoe | [email protected] | | ||
+----+----------+----------------------+ | ||
Page 1 of 1 (Total rows: 2) | ||
``` | ||
|
||
### 4. Pagination | ||
|
||
Use pagination to handle large datasets: | ||
```bash | ||
peepdb view <connection_name> --table <table_name> --page <page_number> --page-size <rows_per_page> | ||
``` | ||
|
||
Example: | ||
```bash | ||
peepdb view myapp_db --table users --page 2 --page-size 50 | ||
``` | ||
|
||
### 5. Choose Output Format | ||
|
||
Get output in JSON format: | ||
```bash | ||
peepdb view <connection_name> --format json | ||
``` | ||
|
||
Example: | ||
```bash | ||
peepdb view myapp_db --table users --format json | ||
``` | ||
|
||
Output: | ||
```json | ||
{ | ||
"users": { | ||
"data": [ | ||
{"id": 1, "username": "johndoe", "email": "[email protected]"}, | ||
{"id": 2, "username": "janedoe", "email": "[email protected]"} | ||
], | ||
"page": 1, | ||
"total_pages": 1, | ||
"total_rows": 2 | ||
} | ||
} | ||
``` | ||
|
||
### 6. Remove Saved Connections | ||
|
||
Remove a specific connection: | ||
|
@@ -107,26 +133,17 @@ Remove all connections: | |
peepdb remove-all | ||
``` | ||
|
||
For more detailed usage information on any command, use the `--help` option: | ||
```bash | ||
peepdb <command> --help | ||
``` | ||
|
||
## 👨💻 For Developers | ||
|
||
Please refer to our [Contributing Guide](CONTRIBUTING.md) for information on setting up the development environment, running tests, and contributing to peepDB. | ||
|
||
## 🔒 Security | ||
|
||
peepDB implements several security measures to protect your database connection details: | ||
|
||
1. **Local Storage**: All connection details are stored locally on your machine, not on any remote servers. | ||
2. **Encryption**: Connection details are encrypted before being stored, using the cryptography library. | ||
3. **Secure Password Input**: Passwords are never shown in plain text and are input securely. | ||
3. **Caution with Passwords**: While passwords are accepted as command-line arguments for convenience, users should be cautious about using this method in shared environments or situations where command history might be accessible to others. | ||
|
||
However, please note that while we strive to implement best security practices, peepDB's security has not been verified by a third party. Users should exercise caution and follow general security best practices when using any tool that handles sensitive information. | ||
## 🤝 Contributing | ||
|
||
The encryption key is stored in your user directory (~/.peepdb/key.key). Keep this key safe and do not share it. | ||
Contributions to peepDB are welcome! Please refer to our [Contributing Guide](CONTRIBUTING.md) for more information. | ||
|
||
## 📜 License | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .mysql import MySQLDatabase | ||
from .postgresql import PostgreSQLDatabase | ||
from .mariadb import MariaDBDatabase |
Oops, something went wrong.