Skip to main content

pisql is a CLI + lightweight python library to interact with a Sybase ASE database.

Project description

License PyPI License

What is pisql ?

pisql is a mix of a command line tool and a small python library to interact with a Sybase ASE database.
It so happens, that I have to work with a Sybase ASE database and I wanted to have a tool to interact with it.

But why ?

The reason I built this is fairly simple although frustrating:

  • My company has tight control over what gets installed on the workstations
  • My company hasn't bought the SQL Anywhere drivers for ASE on top of ASE itself as of today
  • The only way I have to interact with the database is through a very old and ugly piece of software called "sqlDbx".
  • I wanted to have scripting and automation capabilities that the interface couldn't provide, but that bash/powershell/python could.

What is it ?

pisql is, for the CLI part, a rich CLI wrapper around the barebones isql command line tool that comes with the ASE installation every time.

For the python part, it's a small library that allows you to interact with the database through python code. You can turn .sql files into dataframes (pandas or polars), and further manipulate them. You can use every tool you have in python to interact with the data, vizualize it, etc.

How do I use it ?

Installation

You can install pisql through pip:

    pip install pisql

Although I recommend pipx:

    pipx install pisql

This works on Windows, Linux and MacOS.

Usage

CLI

The CLI is fairly simple to use.

To execute a single .sql file, you can just use the exec command:

    pisql exec my_file.sql

which is also aliased to pisql e my_file.sql and pisql x my_file.sql.

To execute multiple .sql files, you can use what I call the "query mode" or "run mode", using either
the symbols q, run or ::. Once this more is activated, you can chain multiple executions together
by using the ++ or // commands:

    pisql q ++ file_one.sql file_two.sql file_three.sql

An important feature of this mode, is that you can list both files and directories.

    pisql :: // file.sql some_dir other_file.sql

What happens then is that pisql will execute sequentially:

  • file.sql first
  • then all the .sql files in some_dir second
  • then other_file.sql last

One nice feature is the presence of rich progress bars like so (give example)

NB: I haven't had the time to implement further recursion, so if you have a directory in some_dir, it will be ignored.

Python

Will explain in the next few days.

What's next ?

I'm currently working on a few things:

  • Implementing a config file subcommand to set the default database, user, etc.
  • Give more freedom to users to change the storage of the dataframes and config files
  • Build a semi ORM to interact with the database through python. Comes to mind the SELECT, WHERE, JOIN, etc. clauses.
  • Have a little templating feature, but nothing too fancy. I don't want to reinvent the wheel here.
  • Use Agg-Grid to have a web interface to interact with the database. I'm not sure how to do this yet, but I'll figure it out.

Here's most of it for now ! I'll update this as I go.

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

pisql-0.1.31.post16.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pisql-0.1.31.post16-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file pisql-0.1.31.post16.tar.gz.

File metadata

  • Download URL: pisql-0.1.31.post16.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.9.13 Windows/10

File hashes

Hashes for pisql-0.1.31.post16.tar.gz
Algorithm Hash digest
SHA256 e0e4f0136cd2018966cb10c57983f37700f16d1a14ad04cdd6d597f90bba492b
MD5 ed1e68b3f63ff90bec0f2a3d4177fd02
BLAKE2b-256 dec4f7875dd2f14e2c09122875ee83a059ac654ff2d71a52d91453c17cea8fbe

See more details on using hashes here.

File details

Details for the file pisql-0.1.31.post16-py3-none-any.whl.

File metadata

  • Download URL: pisql-0.1.31.post16-py3-none-any.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.9.13 Windows/10

File hashes

Hashes for pisql-0.1.31.post16-py3-none-any.whl
Algorithm Hash digest
SHA256 0b83192bbb8aa1b7dd028cb732a6a051f0fb346d29717e2077659c31d191e685
MD5 5d5a8d6cb1a9cf74488f9d173bb0d929
BLAKE2b-256 d0d379897cfe3e7b77af40ccb89a5e94e9831709c252b3642f0536bf2c343837

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page