https://github.com/entorb/sql2csv
connects to DB, reads *.sql files, runs containing select, export as .csv files
https://github.com/entorb/sql2csv
Last synced: over 1 year ago
JSON representation
connects to DB, reads *.sql files, runs containing select, export as .csv files
- Host: GitHub
- URL: https://github.com/entorb/sql2csv
- Owner: entorb
- License: gpl-3.0
- Created: 2021-04-24T10:59:12.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2025-01-07T20:37:50.000Z (over 1 year ago)
- Last Synced: 2025-02-01T13:44:34.066Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 54.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sql2csv
## Features
* connect to a database
* read all .sql files of current directory
* execute one after the other
* export results set as text (.csv) and Excel (.xslx)
## Supported Databases
* PostgreSQL
* Oracle
* MS SQL
* SQLite3
## TODOs
* [x] scan SQL for dangerous commands like DROP/DELETE (incomplete!)
* [x] Limits the max number of returned rows via limit on cells = columns * rows
* [x] hashing of SQL files to prevent modification
* [ ] Excel: autosize column width
* [ ] use [sqlparse](https://sqlparse.readthedocs.io/en/latest/api/) to remove comments from SQL
## **SECURITY WARNING:** Only use read-only db-user accounts
example for PostgreSQL
```sql
GRANT SELECT ON ALL TABLES IN SCHEMA schema_name TO username
GRANT USAGE ON SCHEMA schema_name TO username
```
## Requirements
### Oracle
Oracle Instant Client - Basic Light Package
from
download, unzip and add dir to path
### MS SQL
Microsoft ODBC Driver for SQL Server
from
install