File: README.md

package info (click to toggle)
libsql-tiny-perl 0.04-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 108 kB
  • sloc: perl: 392; makefile: 2
file content (85 lines) | stat: -rw-r--r-- 2,481 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# SQL::Tiny, a Perl module for generating simple SQL statements

A very simple SQL-building library.  It's not for all your SQL needs,
only the very simple ones.

It doesn't handle JOINs.  It doesn't handle subselects.  It's only for simple SQL.

    my ($sql,$binds) = sql_select( 'users', [ 'name', 'status' ], { status => [ 'Deleted', 'Inactive' ] }, { order_by => 'name' } );

    my ($sql,$binds) = sql_insert( 'users', { name => 'Dave', status => 'Active' } );

    my ($sql,$binds) = sql_update( 'users', { status => 'Inactive' }, { password => undef } );

    my ($sql,$binds) = sql_delete( 'users', { status => 'Inactive' } );

In my test suites, I have a lot of ad hoc SQL queries, and it drives me
nuts to have so much SQL code lying around.  SQL::Tiny is for generating
SQL code for simple cases.

I'd far rather have:

    my ($sql,$binds) = sql_insert(
        'users',
        {
            name      => 'Dave',
            salary    => 50000,
            status    => 'Active',
            dateadded => \'SYSDATE()',
        }
    );

than hand-coding:

    my $sql   = 'INSERT INTO users (name,salary,status,dateadded) VALUES (:name,:status,:salary,SYSDATE())';
    my $binds = {
        ':name'      => 'Dave',
        ':salary'    => 50000,
        ':status'    => 'Active',
        ':dateadded' => \'SYSDATE()',
    };

or even the positional:

    my $sql   = 'INSERT INTO users (name,salary,status,dateadded) VALUES (?,?,?,SYSDATE())';
    my $binds = [ 'Dave', 50000, 'Active' ];

# Build status of dev branch

* Travis (Linux) [![Build Status](https://travis-ci.org/petdance/sql-tiny.png?branch=dev)](https://travis-ci.org/petdance/sql-tiny)
* [CPAN Testers](https://cpantesters.org/distro/S/sql-tiny.html)

# Installation

To install this module, run the following commands:

    perl Makefile.PL
    make
    make test
    make install

# Support and Documentation

After installing, you can find documentation for this module with the
perldoc command.

    perldoc SQL::Tiny

You can also look for information at:

    MetaCPAN
        https://metacpan.org/release/SQL-Tiny

    Project home page
        https://github.com/petdance/sql-tiny

    Project issue tracker
        https://github.com/petdance/sql-tiny/issues

# License and Copyright

Copyright (C) 2019 Andy Lester

This program is free software; you can redistribute it and/or modify it
under the terms of the the
[Artistic License 2.0](http://www.perlfoundation.org/artistic_license_2_0).