Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/msabramo/sqlalchemy_sql_shell
A shell for doing simple SQL queries to any database supported by SQLAlchemy
https://github.com/msabramo/sqlalchemy_sql_shell
Last synced: 12 days ago
JSON representation
A shell for doing simple SQL queries to any database supported by SQLAlchemy
- Host: GitHub
- URL: https://github.com/msabramo/sqlalchemy_sql_shell
- Owner: msabramo
- Created: 2012-12-28T23:48:46.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2018-03-04T21:45:43.000Z (almost 7 years ago)
- Last Synced: 2024-12-03T21:57:49.709Z (28 days ago)
- Language: Python
- Size: 258 KB
- Stars: 3
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
sqlalchemy_sql_shell
====================.. image:: https://pypip.in/version/sqlalchemy_sql_shell/badge.svg?style=flat
:target: https://pypi.python.org/pypi/sqlalchemy_sql_shell/
:alt: Latest Version.. image:: https://travis-ci.org/msabramo/sqlalchemy_sql_shell.png?branch=master
:target: https://travis-ci.org/msabramo/sqlalchemy_sql_shellUsage
-----The program takes one argument: a SQLAlchemy database URL of the form:
``dialect+driver://username:password@host:port/database`` (see
`the SQLAlchemy docs on database URLs
`_ for
more info). You may need to install additional packages for your database
driver of choice (e.g.: mysql-python, psycopg2, pymssql, etc.)Here's some basic usage::
$ sqlalchemy_sql_shell
usage: sqlalchemy_sql_shell [-h] url
sqlalchemy_sql_shell: error: too few arguments$ sqlalchemy_sql_shell sqlite:///
SQL> CREATE TABLE people ( first_name VARCHAR(128), last_name VARCHAR(128) );
SQL> INSERT INTO people VALUES ( 'John', 'Doe' ), ('Mike', 'Smith'), ('Guido', 'van Rossum');
result.rowcount = 3
SQL> SELECT * FROM people;
+------------+------------+
| first_name | last_name |
+============+============+
| John | Doe |
| Mike | Smith |
| Guido | van Rossum |
+------------+------------+Multi-line queries are supported; A semi-colon signifies the end of the query::
SQL> SELECT *
...> FROM people
...> ;
+------------+------------+
| first_name | last_name |
+============+============+
| John | Doe |
| Mike | Smith |
| Guido | van Rossum |
+------------+------------+You can also pipe queries into the command for quick one-liners::
$ echo "SELECT 1 + 2;" | sqlalchemy_sql_shell sqlite:///
+-------+
| 1 + 2 |
+=======+
| 3 |
+-------+Or redirect stdin::
$ cat samples/queries.sql
SELECT 1 + 2;
SELECT 3 + 4;
SELECT 5 + 6;$ sqlalchemy_sql_shell sqlite:/// < samples/queries.sql
+-------+
| 1 + 2 |
+=======+
| 3 |
+-------+
+-------+
| 3 + 4 |
+=======+
| 7 |
+-------+
+-------+
| 5 + 6 |
+=======+
| 11 |
+-------+