root/trunk/sdbo/odbc.d

Revision 15, 7.4 kB (checked in by toaster, 8 years ago)

documentation changes

Line 
1 /********************************************************
2  *                                                      *
3  * Copyright (c) 2004 Wolfgang Borgsmüller (wb@sapo.pt) *
4  *                                                      *
5  * Usage of the works is permitted provided that this   *
6  * instrument is retained with the works, so that any   *
7  * entity that uses the works is notified of this       *
8  * instrument.                                          *
9  *                                                      *
10  * DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.          *
11  *                                                      *
12  * [2004, Fair License: rhid.com/fair]                  *
13  ********************************************************/
14
15 /*! \if never
16 */
17  
18 module sdbo.odbc;
19
20
21 import sdbo.odbc_env;
22 import sdbo.odbc_dbc;
23 import sdbo.odbc_stmt;
24 import sdbo.odbc_etc;
25
26 version(linux) {
27     version = bundled_headers;
28 }
29
30 version(bundled_headers) {
31     import sdbo._odbc_headers.sql;
32     import sdbo._odbc_headers.sqlext;
33     import sdbo._odbc_headers.sqltypes;
34     version(Windows)
35         import sdbo._odbc_headers.odbc32dll;
36    
37 } else {
38     import std.c.windows.sql;
39     import std.c.windows.sqlext;
40     import std.c.windows.sqltypes;
41     import std.c.windows.odbc32dll;
42 }
43
44 public alias sdbo.odbc_env.OdbcEnvironment   OdbcEnvironment;
45 public alias sdbo.odbc_dbc.OdbcConnection    OdbcConnection;
46 public alias sdbo.odbc_stmt.SqlResult        SqlResult;
47 public alias sdbo.odbc_etc.ColumnSpec        ColumnSpec;
48 public alias sdbo.odbc_etc.SqlException      SqlException;
49 public alias sdbo.odbc_etc.OdbcMessage       OdbcMessage;
50
51
52 /*! \brief Shortcut for faster typing
53 */
54 public alias OdbcEnvironment DBEnv;
55
56 /*! \brief Shortcut for faster typing
57 */
58 public alias OdbcConnection  DBCon;
59
60 /*! \endif
61 */
62
63  
64  
65 /*! \mainpage
66  *
67  * \section intro_sec Introduction
68  *
69  * The sdbo library is a set of helper classes for use with ODBC database drivers. Runs on Windows and Linux platforms.
70  
71  \subsection needodbc What can I use this library for?
72  
73  You can use it for any database driven application. First of all, you need to decide
74  if you want to use ODBC for your application. There are many articles about this,
75  and lots of discussion going on. The main argument is portability: An application that
76  talks to the odbc driver manager can talk to every databases with an odbc driver.
77  An application that talks to a specific database's native API will need
78  a rewrite to talk to another database.
79  
80  So, if you decide to use ODBC, this package might be interesting for you if you are familiar with SQl but not with ODBC,
81  and you just want to connect to a database and execute query statements, without caring about
82  odbc handles, data types, and API calls.
83  
84  On the other hand, if you need to access the raw odbc api you can still use the classes to hide away
85  bulk operations:
86  
87  <pre>
88  SqlResult r = (new OdbcConnection).connect("someserver").execDirect("select something from somewhere");
89  HSTMT hstmt = r.handle();
90  </pre>
91  
92  
93  *
94  *
95  * \subsection examples_sec Examples
96  
97  This is the Hello world example for sdbo:
98
99  \include test0.d
100     
101 More \ref examples ...
102
103 \section problems Problems
104
105 - This is a 0.1 alpha. Use at your own risk. Don't blame me for nothing.
106 - Cleanup: Handles and memory malloc'd for column bindings are free'd in the
107   class destructors. Needs more testing.
108 - Not enough documentation; author (that's me:) not a native english speaker.
109
110 \section install Installation
111
112
113 \subsection req Requirements:
114
115
116 Version Windows
117 - odbc32.dll required (may also work with another driver manager).
118
119 Version Linux
120 - ODBC Driver Manager (I am testing with iODBC, http://www.iodbc.org)
121
122 All Versions
123 - D Language compiler http://www.digitalmars.com/d/
124 - ODBC Drivers. You need MySQL's MyODBC driver to run the samples in the linux version:
125   http://www.mysql.com/products/connector/odbc/. If you want to run the MySQL samples in the windows version
126   get the MyODBC windows version and change the samples/test*.d files to fit.
127
128  
129 \subsection odbchead ODBC Headers
130
131 - This library requires MKoD's ODBC32.DLL Win32 APIs converted for D.
132 Get it here: http://spottedtiger.tripod.com/D_Language/D_Support_Projects_XP.html
133
134 - std.c.windows.sql;
135 - std.c.windows.sqlext;
136 - std.c.windows.sqltypes;
137 - std.c.windows.odbc32dll;
138
139 Actually I had to do some modifications in the odbc headers for sdbo.lib and libsdbo.a to compile,
140 and MKoD's declaration files are not finished yet, so I bundled a copy of them that
141 works with this project. If the samples wonŽt compile,
142 use -version=bundled_headers which causes the std.c.windows.* modules to be ignored
143 and the bundled headers to be used. The bundled headers are going to disappear as soon
144 as the MKoD headers are in a stable release.
145
146 The linux version always compiles with the bundled headers.
147
148 \subsection inst Install:
149
150 All Versions
151 - Install the sdbo directory in your include path.
152
153 Version Windows
154 - Copy sdbo.lib into your library path.
155
156 Version Linux
157 - Copy libsdbo.a into your library path.
158
159
160 \subsection cmp Compile test:
161
162 Version Windows
163
164 - On a command line, do:
165 <pre>
166 ECHO import sdbo.odbc; void main() { (new OdbcEnvironment).connect("foobar"); } > odbc_test.d
167 dmd odbc_test.d sdbo.lib
168 odbc_test
169 </pre>
170 - If that won't compile, use
171 <pre>
172 dmd -version=bundled_headers odbc_test.d sdbo.lib
173 odbc_test
174 </pre>
175
176 Version Linux
177
178 - On a command line, do:
179 <pre>
180 echo "import sdbo.odbc; void main() { (new OdbcEnvironment).connect(\"foobar\"); }" > odbc_test.d
181 dmd -c odbc_test.d [-I/path/to/simple]
182 gcc -o odbc_test odbc_test.o -lsdbo -lphobos -lpthread -lm -lodbc
183 </pre>
184
185 - Or
186 <pre>
187 dmd -c odbc_test.d [-I/path/to/simple]
188 gcc -o odbc_test odbc_test.o /path/to/libodbc.a -lphobos -lpthread -lm -lodbc
189 </pre>
190
191 - "-lphobos -lpthread -lm" are the libraries dmd would have passed to gcc if not called with -c
192 - "-lodbc" is the odbc driver manager. The package is being tested for the iODBC manager.
193 - Link the sdbo library before the phobos library.
194
195
196 \subsection versions Versions:
197
198 The version of this package is 0.1.
199
200 0.1 just means it is not finished yet.
201 The package release is a zip file in the project's svn at dsource.org.
202 The zip is called "sdbo-0.1.*.zip, being * an incremental number idicating changes to the 0.1 package.
203 I am trying to maintain the zip file synchronized with the trunk.
204 Compare the last digit of the file you downloaded and the file available here:
205 http://svn.dsource.org/svn/projects/sdbo/downloads/
206 If they differ, your package is not up to date.
207
208 Starting from 0.1.6, there is now a package sdbo-0.1.*.tar.gz. The content is identical.
209
210
211 \section todo Todo:
212
213 - Finish the existing classes and expose more funcionality like parameter bound query execution, etc.
214   At this time, you have to use the handles to do that.
215  
216 - If you are using or testing this set of classes, I would be glad to hear your suggestions.
217   Use the project forum at http://dsource.org - suggestions, criticism, anything.
218
219 \section links Links:
220
221 - This project is hosted at http://dsource.org
222  *
223  */
224  
225 /*!
226  \page examples Examples
227  
228  \section test1 test1.d
229  
230  \include test1.d
231  
232  \section test2 test2.d
233  
234  \include test2.d
235  
236  \section test3 test3.d
237  
238  \include test3.d
239  
240  \section test4 test4.d
241  
242  \include test4.d
243  
244  \section test5 test5.d
245  
246  \include test5.d
247  
248  
249  */
250  
Note: See TracBrowser for help on using the browser.