O'Reilly logo

Python Programming On Win32 by Mark Hammond, Andy Robinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Module Interface

Access to the database is made available through connection objects. The module must provide the following constructor for these:

connect( parameters ...)

Constructor for creating a connection to the database. Returns a Connection object. It takes a number of parameters that are database dependent.Note 1

These module globals must be defined:

apilevel

String constant stating the supported DB API level. Currently only the strings 1.0 and 2.0 are allowed. If not given, a Database API 1.0 level interface should be assumed.

threadsafety

Integer constant stating the level of thread safety the interface supports. Possible values are:

0 = Threads may not share the module.

1 = Threads may share the module, but not connections.

2 = Threads may share the module and connections.

3 = Threads may share the module, connections, and cursors.

Sharing in this context means that two threads may use a resource without wrapping it using a mutex semaphore to implement resource locking. You can’t always make external resources thread-safe by managing access using a mutex: the resource may rely on global variables or other external sources that are beyond your control.

paramstyle

String constant stating the type of parameter marker formatting expected by the interface. Possible values are:Note 2

qmark = Question-mark style, e.g., ...WHERE name=?

numeric = Numeric, positional style, e.g., ...WHERE name=:1

named = Named style, e.g., ...WHERE name=:name

format = ANSI C printf format codes, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required