Documentation

#SQLDB

Added in v3.11

SQLDB

Syntax: #SQLDB filename
Syntax: #SQLDB name dbname protocol server port user pass
Related: %sql, %sqldb, #SQLCLOSE

Creates a new SQL Database connection and automatically opens it. To create a connection without automatically opening it, see the %sqldb function.

When just a filename is used, the format of the database is assumed to be SQLite. The "name" of the database connection object is taken from the filename without the extension.

When the full form of the #SQLDB command is used, the "name" of the connection can be set differently from the database name (filename for local databases), and additional SQL protocols can be used.

The following additional protocols can be used within TeSSH:
  • ado Microsoft ADO/MDAC using any ODBC, DSN, or OLEDB driver installed on your system. The dbname should be a full OLE connection string.
  • sqlite, sqlite-2.8, sqlite-3 : SQLite (sqlite.dll, sqlite3.dll)
  • firebird-1.5, firebird-2.0 : Firebird (fbclient15.dll, fbclient20.dll)
  • firebirdd-1.5, firebirdd-2.0 : Firebird (Embedded) (fbclientd15.dll, fbclientd20.dll)
  • interbase-5, interbase-6 : Interbase (gds32.dll)
  • mssql : Microsoft SQL Server 1.7 (ntwdblib.dll)
  • mysql, mysql-4.1, mysql-5 : MySQL v4.1, v5.0 or v5.1 (libmysql41.dll, libmysql50.dll, libmysql51.dll)
  • mysqld, mysqld-4.1, mysqld-5 : MySQL Embedded v4.1, v5.0 or v5.1 (libmysqld41.dll, libmysqld50.dll, libmysqld51.dll)
  • oracle, oracle-9i : Oracle (oci.dll)
  • postgresql, postgresql-7, postgresql-8 : PostgreSQL v7 or v8 (libpq.dll, libpq74.dll, libpq81.dll)
  • sybase : Sybase 1.25 (libsybdb.dll)

Note that you must have the proper DLL driver for the database protocol in the same directory as your EXE file. These DLLs are usually obtained from the database provider. TeSSH uses the open-source ZeosLib database components (v6.6) which are based upon JDBC drivers. Drivers other than SQLite have not been fully tested by Zugg Software.

SQLDB examples

#SQLDB sessions.db
row = %sql(sessions, "SELECT * FROM chardb")
#WHILE (!@row.Eof()) {#SHOW @row.Item("Title");#CALL @row.Next}
#SQLCLOSE sessions

Loops through the local "sessions.db" SQLite database and displays the Title of each session.

#SQLDB mydb dbname mysql hostname.com 3305 root passwd

Add comment

Login or register to post comments