Ignore:
Timestamp:
01/25/08 20:42:44 (13 years ago)
Author:
Kon Lovett
Message:

1.3 release. Moved aux C code into .scm file. Added mysql-options conn arg helper.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/3/mysql/trunk/mysql-tests-body.scm

    r7926 r7930  
    44
    55(use mysql)
     6
     7;;;
    68
    79(define (collect-until proc pred)
     
    1315  (collect-until proc (complement pred)) )
    1416
    15 (define (mysql-fetch-field-items conn . getters)
    16   (collect-while (lambda () (apply mysql-fetch-field-slots conn getters)) identity) )
     17;;;
    1718
    1819(define (mysql-fetch-field-item conn getter)
    1920  (collect-while (lambda () (mysql-fetch-field-slot conn getter)) identity) )
    2021
     22#; ;UNUSED
     23(define (mysql-fetch-field-items conn . getters)
     24  (collect-while (lambda () (apply mysql-fetch-field-slots conn getters)) identity) )
     25
     26;;;
     27
    2128(print "Opening the connection")
    22 (define *db* (mysql-connect user: *user* passwd: *passwd* host: *host*))
    23 (print "Database: " *db*)
     29(define *conn* (mysql-connect user: *user* passwd: *passwd* host: *host*))
     30(print "Database: " *conn*)
    2431
    25 (unless *db*
     32(unless *conn*
    2633  (print "Unable to connect to database.")
    2734  (print "You might want to edit \"mysql-tests.scm\" to set *user*, *passwd*, and *host*.")
    2835  (exit) )
    2936
    30 (print "MySQL errno: " (mysql-errno *db*))
    31 (print "MySQL error: " (mysql-error *db*))
     37(print "MySQL errno: " (mysql-errno *conn*))
     38(print "MySQL error: " (mysql-error *conn*))
    3239(newline)
    3340
    34 (define (mysql-print-and-query *db* query)
     41(define (mysql-print-and-query *conn* query)
    3542  (print "QUERY: " query)
    36   (mysql-query *db* query))
     43  (mysql-query *conn* query))
    3744
    3845(print "Performing query: SHOW DATABASES")
    39 (mysql-print-and-query *db* "SHOW DATABASES")
    40 (print "Number of rows: " (mysql-num-rows *db*))
     46(mysql-print-and-query *conn* "SHOW DATABASES")
     47(print "Number of rows: " (mysql-num-rows *conn*))
    4148
    4249(newline)
    4350(print "The rows can be enumerated one-per-line, like this:")
    44 (mysql-foreach-row *db* (lambda (row row-idx)
     51(mysql-foreach-row *conn* (lambda (row row-idx)
    4552  (display (conc row-idx ": " (row "Database") "\n"))))
    4653
    4754(newline)
    4855(display "Or they can just be comma-separated, like so:")
    49 (mysql-foreach-row *db* (lambda (row row-idx)
     56(mysql-foreach-row *conn* (lambda (row row-idx)
    5057  (display (conc (row "Database")
    51                  (if (< row-idx (mysql-num-rows *db*)) ", " "\n")))))
     58                 (if (< row-idx (mysql-num-rows *conn*)) ", " "\n")))))
    5259
    53 (mysql-print-and-query *db* "DROP DATABASE IF EXISTS mysql_egg_test")
     60(mysql-print-and-query *conn* "DROP DATABASE IF EXISTS mysql_egg_test")
    5461
    55 (mysql-print-and-query *db* "CREATE DATABASE mysql_egg_test")
     62(mysql-print-and-query *conn* "CREATE DATABASE mysql_egg_test")
    5663
    5764(print "selecting database: mysql_egg_test")
    58 (mysql-select-db *db* "mysql_egg_test")
     65(mysql-select-db *conn* "mysql_egg_test")
    5966
    6067(newline)
    61 (mysql-print-and-query *db* "CREATE TABLE test1 (
     68(mysql-print-and-query *conn* "CREATE TABLE test1 (
    6269  id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    6370  testboolnn BOOLEAN NOT NULL,
     
    6673
    6774(newline)
    68 (mysql-print-and-query *db*
     75(mysql-print-and-query *conn*
    6976  "INSERT INTO test1 SET testboolnn=TRUE, testbool=NULL")
    70 (mysql-print-and-query *db*
     77(mysql-print-and-query *conn*
    7178  "INSERT INTO test1 SET testboolnn=FALSE, testbool=FALSE")
    7279
    7380(newline)
    74 (mysql-print-and-query *db* "SELECT testboolnn, testbool FROM test1")
    75 (mysql-foreach-row *db* (lambda (row idx)
     81(mysql-print-and-query *conn* "SELECT testboolnn, testbool FROM test1")
     82(mysql-foreach-row *conn* (lambda (row idx)
    7683  (display (conc "row " idx ": testboolnn=" (row "testboolnn")
    7784                 ", testbool="
     
    7986
    8087(newline)
    81 (mysql-print-and-query *db* "SELECT testboolnn, testbool FROM test1")
    82 (let ([names (mysql-fetch-field-item *db* mysql-field-name)])
     88(mysql-print-and-query *conn* "SELECT testboolnn, testbool FROM test1")
     89(let ([names (mysql-fetch-field-item *conn* mysql-field-name)])
    8390  (pretty-print
    8491   (mysql-row-map
    85      *db*
     92     *conn*
    8693     (lambda (row idx)
    8794       (map (lambda (f) (cons f (row f))) names)))) )
    8895
    8996(newline)
    90 (mysql-print-and-query *db* "SELECT testboolnn, testbool FROM test1")
     97(mysql-print-and-query *conn* "SELECT testboolnn, testbool FROM test1")
    9198(mysql-row-for-each
    92   *db*
     99  *conn*
    93100  (lambda (row idx)
    94     (print "Row " idx " lengths: " (mysql-fetch-lengths *db*))))
     101    (print "Row " idx " lengths: " (mysql-fetch-lengths *conn*))))
    95102
    96103;; Finished
    97104(newline)
    98105(print "Closing the connection")
    99 (mysql-close *db*)
     106(mysql-close *conn*)
Note: See TracChangeset for help on using the changeset viewer.