The SQL Data Frames Reference Manual

The SQL Data Frames Reference Manual

This is the SQL Data Frames Reference Manual, version 1.0.0, generated automatically by Declt version 4.0b2.

Copyright © 2019-2022 Steve Nunez

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the section entitled “Copying” is included exactly as in the original.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be translated as well.

Table of Contents


Copying

This program is distributed under the terms of the Microsoft Public License.


1 Systems

The main system appears first, followed by any subsystem dependency.


1.1 sqldf

A wrapper for SQLite allowing querying of Data Frames

Long Name

SQL queries for Data Frames

Author

Steve Nunez <steve@symbolics.tech>

Home Page

http://lisp-stat.dev/docs/manuals/sqldf

Source Control

(GIT git://github.com/Lisp-Stat/sqldf)

Bug Tracker

https://github.com/Lisp-Stat/sqldf/issues

License

MS-PL

Long Description

SQLDF is a library for querying data frames using SQL, optimised for convenience over memory consumption. It uses an in-memory data base for transparent queries.

Version

1.0.0

Dependencies
  • sqlite (system).
  • data-frame (system).
  • select (system).
Source

sqldf.asd.

Child Components

2 Files

Files are sorted by type and then listed depth-first from the systems components trees.


2.1 Lisp


2.1.1 sqldf/sqldf.asd

Source

sqldf.asd.

Parent Component

sqldf (system).

ASDF Systems

sqldf.


2.1.2 sqldf/pkgdcl.lisp

Source

sqldf.asd.

Parent Component

sqldf (system).

Packages

sqldf.


2.1.3 sqldf/utils.lisp

Dependency

pkgdcl.lisp (file).

Source

sqldf.asd.

Parent Component

sqldf (system).

Internals

2.1.4 sqldf/sqldf.lisp

Dependency

utils.lisp (file).

Source

sqldf.asd.

Parent Component

sqldf (system).

Public Interface
Internals

create-df-table (function).


3 Packages

Packages are listed by definition order.


3.1 sqldf

SQLDF is a facility for querying data frames with SQL

Source

pkgdcl.lisp.

Use List

common-lisp.

Public Interface
Internals

4 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


4.1 Public Interface


4.1.1 Ordinary functions

Function: read-table (db table)

Read TABLE and return a data frame with the contents. Keys are interned in a package with the same name as TABLE.

Package

sqldf.

Source

sqldf.lisp.

Function: sqldf (sql)

Execute SQL (a string) on a data frame and return a new data frame with the results.
The data frame is identified by the word following FROM (case insensitive) in the SQL string. An in-memory SQLite database is creaetd, the contents of the data frame loaded, the query performed and a new DATA-FRAME returned with the results and the database deleted. In most cases, using this library is faster, from a developers time perspective, than writing the code to perform the same query. SQLDF has been tested with data frames of 350K rows with no slow-down noted. The R documentation for their version of SQLDF suggests that it could be faster than Lisp native queries. Note that the SQL query must use SQL style names for columns and not the Lisp versions, e.g. flight-time becomes flight_time.

Package

sqldf.

Source

sqldf.lisp.

Function: write-table (db table df)

Write data-frame DF to TABLE on connection DB. :na symbols are converted to "NA" strings in the database.

Package

sqldf.

Source

sqldf.lisp.


4.2 Internals


4.2.1 Special variables

Special Variable: *downcase-symbols*
Package

sqldf.

Source

utils.lisp.

Special Variable: *escape-sql-names-p*
Package

sqldf.

Source

utils.lisp.

Special Variable: *sqlite-reserved-words*
Package

sqldf.

Source

utils.lisp.


4.2.2 Ordinary functions

Function: create-df-table (db table df)

Create a database table of NAME in DB according to the schema of DF. This function is to create a table for DF prior to loading. Lisp style symbol names are converted to SQL compatible names.

Package

sqldf.

Source

sqldf.lisp.

Function: execute-to-column (db sql &rest parameters)
Package

sqldf.

Source

utils.lisp.

Function: from-sql-name (str)

Convert a string to a symbol, upcasing and replacing underscores with hyphens.

Package

sqldf.

Source

utils.lisp.

Function: sqlite-column-type (sequence)

Return a format string for the most general type found in sequence
Use this for sequences of type T to determine how to declare the column to SQLite.

Package

sqldf.

Source

utils.lisp.

Function: statement-column-type (stmt column-number)

Return the type string of a column of a query statement

Package

sqldf.

Source

utils.lisp.

Function: to-sql-name ()

Convert a symbol or string into a name that can be a sql table, column, or operation name. Add quotes when escape-p is true, or escape-p is :auto and the name contains reserved words. Quoted or delimited identifiers can be used by passing :literal as the value of escape-p. If escape-p is :literal, and the name is a string then the string is still escaped but the symbol or string is not downcased, regardless of the setting for *downcase-symbols* and the hyphen and forward slash characters are not replaced with underscores. Ignore-reserved-words is only used internally for column names which are allowed to be reserved words, but it is not recommended.

Package

sqldf.

Source

utils.lisp.


Appendix A Indexes


A.1 Concepts