• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

Makefiles/H03-May-2022-13394

AUTHORSH A D05-Oct-201032 21

COPYINGH A D05-Oct-201024.7 KiB482399

ChangeLogH A D05-Oct-20105 KiB158110

INSTALLH A D05-Oct-20104.6 KiB15196

READMEH A D05-Oct-20104.5 KiB158119

README.textH A D05-Oct-20101.5 KiB5029

common.cH A D05-Oct-20102.6 KiB14198

common.hH A D05-Oct-20101.4 KiB4016

config.inH A D03-May-20223.1 KiB11082

configureH A D05-Oct-20109.1 KiB397360

gdbm_driver.cH A D05-Oct-20103.9 KiB200153

ingres_driver.cH A D05-Oct-201011.2 KiB391305

lago_driver.cH A D05-Oct-20102.5 KiB11273

mimer_driver.cH A D05-Oct-2010915 328

mimer_driver.ecH A D05-Oct-20109.3 KiB413352

mimer_driver.iH A D05-Oct-201019.1 KiB987680

msql_driver.cH A D05-Oct-20102.8 KiB13290

mysql_driver.cH A D05-Oct-20102.9 KiB13392

odbc_driver.cH A D05-Oct-20104.6 KiB157121

oracle_driver.cH A D05-Oct-20107 KiB323263

postgres_driver.cH A D05-Oct-20103.3 KiB144100

sdb-config.shH A D05-Oct-2010452 4938

sdb.3H A D05-Oct-20104 KiB160130

sdb.cH A D05-Oct-20106.4 KiB264209

sdb.hH A D05-Oct-20101.3 KiB3212

sdb_client.cH A D05-Oct-20101.7 KiB10990

sdb_close.3H A D05-Oct-201015 21

sdb_init.3H A D05-Oct-201015 21

sdb_open.3H A D05-Oct-201015 21

sdb_query.3H A D05-Oct-201015 21

sdbd.8H A D05-Oct-20101.1 KiB3928

sdbd.cH A D05-Oct-20105 KiB232190

sdbd_client.cH A D05-Oct-20101 KiB5543

sdbd_driver.cH A D05-Oct-20105.8 KiB288228

shsql_driver.cH A D05-Oct-20102.4 KiB10968

sqlite3_driver.cH A D05-Oct-20102.7 KiB12478

sqlite_driver.cH A D05-Oct-20102.7 KiB12478

squid_sdb_auth.cH A D05-Oct-20101 KiB5947

tds_driver.cH A D05-Oct-20109.1 KiB365273

text_driver.cH A D05-Oct-201023.6 KiB1,099751

README

1
2Author: Ulric Eriksson (ulric@siag.nu)
3
4This is libsdb, the simple database library, which provides a way
5to support multiple database management systems in an application
6with negligeable overhead, in terms of code as well as system
7resources.
8
9Supported databases:
10
11 - Gdbm
12 - Ingres
13 - Lago
14 - Microsoft SQL (requires freetds >= 0.64)
15 - Mimer
16 - Msql
17 - Mysql
18 - ODBC
19 - Oracle
20 - Postgresql
21 - Sdbd (libsdb proxy)
22 - Shsql/quisp
23 - Sqlite versions 2 and 3
24 - Sybase (untested, see Microsoft SQL)
25 - Text
26
27The driver for ODBC can be used for any database
28supported by UnixODBC, including Sybase. It can also
29be on Windows for access to any database which has a
30Windows ODBC driver.
31
32Gdbm does not use SQL. See gdbm.c for usage.
33
34
35Installation
36------------
37
38See INSTALL for installation instructions.
39
40
41Database interface
42------------------
43
44The database interface is a single function, sdb_query. Synopsis:
45
46        int sdb_query(char *url, char *query,
47                int (*callback)(int, char **, void *), void *closure)
48
49url is a string which identifies the driver and any necessary options
50such as the name of the database and user. The set of options is
51driver specific. Examples:
52
53	ingres:db=XXX
54        mysql:host=XXX:db=XXX:uid=XXX:pwd=XXX
55        postgres:host=XXX:db=XXX:port=XXX
56        oracle:uid=XXX:pwd=XXX OR oracle:uid=username/password@instance
57        sqlite:db=/full/path/to/db
58        sqlite3:db=/full/path/to/db
59        lago:host=XXX:port=XXX:db=XXX:uid=XXX:pwd=XXX
60        mimer:db=XXX:uid=XXX:pwd=XXX
61        odbc:dsn=postgresql
62	sdbd:host:port:url=XXX
63	shsql: (path to db in SHSQL_DB environment variable)
64	tds:host=XXX:port=XXX:uid=XXX:pwd=XXX
65	text:/path/to/db/ (note trailing slash)
66
67Some drivers also get parameters from environment variables, such
68as ORACLE_SID.
69
70query is an SQL string sent to the database, such as
71
72        select count(*) from crontab where host='myhost'
73
74sdb_query calls the callback once for each row returned. No rows does
75not necessarily indicate an error condition; for example
76
77        delete from crontab where host='myhost'
78
79does not return anything. sdb_query returns the number of rows or -1
80for error.
81
82The callback takes three arguments, an integer indicating the number
83of columns in the reply, an array of pointers to the fields and a
84pointer to some arbitrary data that the callback might need.
85Values are always returned as strings. Synopsis:
86
87        int callback(int n, char **p, void *closure)
88
89The file sdb_client.c contains a very simple line-mode client. Example:
90
91sh-2.03$ ./sdb_client oracle:uid=system/manager@ulric
92sdb> select * from counters
93serialno 1
94serial 17
95Return code: 2
96sdb> update counters set value=2 where name='serialno'
97Return code: 0
98sdb> select * from counters
99serialno 2
100serial 17
101Return code: 2
102sdb>
103
104
105Proxy daemon
106------------
107
108Sometimes linking directly with the library isn't practical,
109perhaps because an application is being distributed in binary form
110and there's no way to know what database will be used, or perhaps
111the application will be run on a different machine from where the
112database client libraries are installed.
113
114Sdbd to the rescue! This is a proxy daemon which handles the database
115communication on behalf of the application. As a result, there is
116no need for the application to be linked to database libraries or even
117libsdb itself; all that is handled by sdbd.
118
119An example client is provided in sdbd_client.c. It is very similar
120to sdb_client, except that it doesn't use any libsdb calls. Example:
121
122ulric@host1$ sdbd 2222
123
124ulric@host2$ sdbd_client host1 2222 postgres:host=host1:db=testdb
125sdbd> select * from foo
126Matilda Eriksson
127Ulric Eriksson
128Joel Eriksson
129sdbd>
130
131In this case, the database, the client libraries and libsdb are all
132installed on host1. Nothing except sdbd_client is needed on host2.
133
134Description of the protocol, as seen on the wire:
135
1361. Client sends url
1372. Server sends single space as acknowledgement
1383. Client sends query string
1394. Server sends number of columns in result, space-terminated
1405. Server sends column size in bytes, space-terminated
1416. Server sends column contents
1427. 5-6 are repeated for all additional columns
1438. 4-7 are repeated for all additional result rows
1449. Server sends the number 0.
145
146Everything is sent in ascii form, so it can be debugged by humans.
147Example:
148
149sh-2.05$ telnet localhost 2222
150Trying 127.0.0.1...
151Connected to localhost.
152Escape character is '^]'.
153postgres:host=localhost:db=testdb
154 select * from foo
1552 7 Matilda8 Eriksson2 5 Ulric8 Eriksson2 4 Joel8 Eriksson0
156Connection closed by foreign host.
157
158

README.text

1
2Author: Lahcen EL HADDATI (elhaddati@hotmail.com)
3
4This is text_driver, the same thing as mysql_driver but it gets
5information from a text file. The text file must be like this :
6
7{name}|{email}|{adress}|{phone}|
8Marry|marry@mail.com|Paris|00-11-22-33-44|
9Jean|jean@mail.com|London|00-33-33-33-33|
10Paul|paul@mail.com|Washington|00-77-66-55-44|
11Lahcen|lahcen@mail.com|Tokyo|00-88-22-77-44|
12Nicolas|nicolas@mail.com|Caen|00-44-88-00-44|
13
14
15
16We use a single function, text_driver:
17
18static int text_driver(void *pdb, char *d, char *q,
19	int (*callback)(int, char **, void *), void *closure)
20
21*- d is the directory where the text file is.
22
23*- q is a query like an SQL string , such as
24
25        select * from file where name='lahcen'
26
27but it does not support queries like :
28        select count(*) from ...
29or      select * from file where name='lehcen' and phone='....'
30
31
32text_driver calls the callback once for each row returned. No rows does
33not necessarily indicate an error condition;
34
35 text_driver returns the number of rows or -1 for error.
36
37*- The callback takes three arguments, an integer indicating the number
38of columns in the reply, an array of pointers to the fields and a
39pointer to some arbitrary data that the callback might need.
40Values are always returned as strings. Synopsis:
41
42        int callback(int n, char **p, void *closure)
43
44
45
46
47N.B. I did that text_driver very very quickly, because I have to use it.
48So it is not well done but it works. And I think that there is some bugs
49that I'll try to resolve when I'll have time.
50