1
0
Fork 0

Merge remote-tracking branch 'upstream/master'

This commit is contained in:
darikg 2015-01-07 18:53:30 -05:00
commit c9968eb0cc
10 changed files with 47 additions and 30 deletions

View File

@ -1,10 +1,10 @@
language: python
python:
- "3.4"
- "3.3"
- "2.7"
- "2.6"
env:
- TOX_ENV=py26
- TOX_ENV=py27
- TOX_ENV=py33
- TOX_ENV=py34
install: pip install tox
script: tox
script: tox -e $TOX_ENV

View File

@ -2,7 +2,14 @@ Many thanks to the following contributors.
Contributors:
-------------
* Iryna Truong
Iryna Cherniavska
Karl-Aksel Puulmann
Guewen Baconnier
Hans Roman
Sven-Hendrik Haase
dwalmsley
Charlie Arnold
Eric Workman
Creator:
--------

View File

@ -11,13 +11,13 @@ This is a postgres client that does auto-completion and syntax highlighting.
Quick Start
-----------
If you already know how to install python pacakges, then you can simply do:
If you already know how to install python packages, then you can simply do:
::
$ pip install pgcli
If you don't know how to install python pacakges, please check the
If you don't know how to install python packages, please check the
`detailed instructions`__.
__ https://github.com/amjith/pgcli#detailed-installation-instructions
@ -57,6 +57,7 @@ The `pgcli` is written using prompt_toolkit_.
* Config file is automatically created at ~/.pglirc at first launch.
* Primitive support for `psql` back-slash commands.
* Pretty prints tabular data.
.. _prompt_toolkit: https://github.com/jonathanslenders/python-prompt-toolkit
@ -78,7 +79,7 @@ Detailed Installation Instructions:
OS X:
=====
For installing Python pacakges it is recommended to use the package manager
For installing Python packages it is recommended to use the package manager
called `pip`. Check if `pip` is installed on the system.
::
@ -104,7 +105,7 @@ If pip is not installed check if easy_install is available on the system.
$ which easy_install
$ sudo easy_install install pgcli
$ sudo easy_install pgcli
Linux:
======
@ -149,7 +150,7 @@ Jonathan has also provided valuable feedback and support during the development
of this app.
This app includes the awesome `tabulate <https://pypi.python.org/pypi/tabulate>`_
library for printing the output of tables. The reason for vendoring this
library for pretty printing the output of tables. The reason for vendoring this
library rather than listing it as a dependency in setup.py, is because I had to
make a change to the table format which is merged back into the original repo,
but not yet released inPyPI.
@ -158,7 +159,7 @@ but not yet released inPyPI.
and printing error messages.
Thanks to `psycopg <http://initd.org/psycopg/>`_ for providing a rock solid
interface to Postgres dataabase.
interface to Postgres database.
Thanks to all the beta testers and contributors for your time and patience. :)

View File

@ -1 +1 @@
__version__ = '0.10.0'
__version__ = '0.10.2'

View File

@ -3,6 +3,7 @@ from __future__ import unicode_literals
from __future__ import print_function
import os
import traceback
import logging
import click
@ -101,8 +102,8 @@ def cli(database, user, host, port, prompt_passwd, never_prompt):
raise e
except Exception as e: # Connecting to a database could fail.
_logger.debug('Database connection failed: %r.', e.message)
click.secho(e.message, err=True, fg='red')
_logger.debug('Database connection failed: %r.', e)
click.secho(str(e), err=True, fg='red')
exit(1)
layout = Layout(before_input=DefaultPrompt('%s> ' % pgexecute.dbname),
menus=[CompletionsMenu(max_height=10)],
@ -142,8 +143,9 @@ def cli(database, user, host, port, prompt_passwd, never_prompt):
_logger.debug("status: %r", status)
click.echo_via_pager('\n'.join(output))
except Exception as e:
_logger.debug("sql: %r, error: %r", document.text, e.message)
click.secho(e.message, err=True, fg='red')
_logger.error("sql: %r, error: %r", document.text, e)
_logger.error("traceback: %r", traceback.format_exc())
click.secho(str(e), err=True, fg='red')
# Refresh the table names and column names if necessary.
if need_completion_refresh(document.text):
@ -207,3 +209,6 @@ def refresh_completions(pgexecute, completer):
for table in tables:
completer.extend_column_names(table, pgexecute.columns(table))
completer.extend_database_names(pgexecute.databases())
if __name__ == "__main__":
cli()

View File

@ -23,7 +23,9 @@ class MockLogging(object):
def parse_special_command(sql):
command, _, arg = sql.partition(' ')
verbose = '+' in command
return (command.strip(), verbose, arg.strip())
command = command.strip().replace('+', '')
return (command, verbose, arg.strip())
def describe_table_details(cur, pattern, verbose):
"""

View File

@ -1,9 +1,15 @@
import logging
import psycopg2
import psycopg2.extensions
from .packages import pgspecial
_logger = logging.getLogger(__name__)
# Cast all database input to unicode automatically.
# See http://initd.org/psycopg/docs/usage.html#unicode-handling for more info.
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)
def _parse_dsn(dsn, default_user, default_password, default_host,
default_port):
"""
@ -88,7 +94,7 @@ class PGExecute(object):
try:
dbname = sql.split()[1]
except:
_logger.debug('Failed to switch. DB missing: %r', dbname)
_logger.debug('Database name missing.')
raise RuntimeError('Database name missing.')
self.conn = psycopg2.connect(database=dbname,
user=self.user, password=self.password, host=self.host,

View File

@ -23,10 +23,12 @@ setup(
description=description,
long_description=open('README.rst').read(),
install_requires=[
'Click',
'prompt_toolkit',
'click >= 3.2',
'Pygments >= 2.0', # Pygments has to be Capitalcased. WTF?
'jedi == 0.8.1', # Temporary fix for installation woes.
'prompt_toolkit==0.25', # Need to pin this to 0.25 since APIs change quite a bit after this.
'psycopg2 >= 2.5.4',
'sqlparse',
'sqlparse >= 0.1.14',
],
entry_points='''
[console_scripts]

View File

@ -1,6 +0,0 @@
[tox]
envlist = py26, py27, py33, py34
[testenv]
deps = pytest
commands = py.test

View File

@ -1,5 +1,5 @@
[tox]
envlist = py26, py27, py33
envlist = py26, py27, py33, py34
[testenv]
deps = pytest
mock