A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://preql.readthedocs.io/en/latest/getting-started.html below:

Getting Started — Preql documentation

Preql Getting Started¶ Install¶
  1. Ensure you have Python 3.6, or above, installed on your system.
  2. Ensure you have pip for Python (you probably already do).
  3. Run the following command:
Run the interpreter in the console (REPL)¶

To start the interpreter, run the following in your shell:

Preql will use Sqlite’s memory database by default.

To see the running options, type:

Explore an existing database¶

When you start the interpreter, you can specify which database to connect to, using a URL.

    # Postgresql
    preql postgres://user:pass@host/dbname

    # MySQL
    preql mysql://user:pass@host/dbname

    # Sqlite (use existing or create new)
    preql sqlite://path/to/file

When already inside the Preql interactive prompt, a Jupyter Notebook, or a running script, use the connect() method:

    connect("sqlite://path/to/file")

Use introspective methods to see a list of the tables, and of the available functions:

    // Get a list of all tables in database
    >> tables()

    // Get help regarding how to use Preql
    >> help()

    // For example:
    >> help(connect)
    func connect(uri, load_all_tables, auto_create) = ...

        Connect to a new database, specified by the uri
        ...
Run in a Jupyter Notebook¶
  1. Install the Preql kernel into jupyter:
  1. Run Jupyter Notebook as usual:
  1. create a new notebook with the Preql kernel, or open an existing one.

Inside the notebook, use the connect() function to connect to a database.

For an example, view the following Jupyter notebook: Tutorial: Exploring a database with Preql

Use as a Python library¶
from preql import Preql
p1 = Preql()                             # Use memory database
p2 = Preql("sqlite://path/to/file")     # Use existing or new file

assert p1('sum([1..10])') == 45
Run as a REST / GraphQL server¶

Coming soon!


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4