pyodbc - A Python DB API module for ODBC

This module implements the Python Database API Specification, so you should first be familiar with it.

Quick Examples

Make a direct connection to a database and create a cursor:

  cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=localhost;DATABASE=testdb;UID=me;PWD=pass')
  cursor = cnxn.cursor()

Select some values and print them:

  cursor.execute("select user_id, user_name from users")
  for row in cursor:
      print row.user_id, row.user_name

Select the values, but use a more compact form. The execute function returns the cursor object when a SELECT is executed, so execute can be moved into the for loop:

  for row in cursor.execute("select user_id, user_name from users"):
      print row.user_id, row.user_name

Select a calculated value, giving it a name:

  cursor.execute("select count(*) as user_count from users")
  row = cursor.fetchone()
  print '%d users' % row.user_count

Supply parameters:

  cursor.execute("select count(*) as user_count from users where age > ?", 21)
  row = cursor.fetchone()
  print '%d users' % row.user_count

Delete some records and retrieve the count:

  count = cursor.execute("delete from users where age < ?", 18)
  print "deleted %s users" % count

Module Interface

connect(connectionstring, autocommit=False)

connectionstring
The ODBC connection string.
autocommit
A Boolean that determines if the connection should be in autocommit mode or manual-commit mode.

Returns a new Connection object.

The connection string is passed unmodified to SQLDriverConnect. Connection strings can have driver specific components and you should refer to the SQLDriverConnect or other ODBC documentation for details, but below are two common examples.

To connect using a DSN (a data source specified in the Data Access control panel applet), use a string similar to the following.

  cnxn = pyodbc.connect("DSN=dsnname")
  cnxn = pyodbc.connect("DSN=dsnname;PWD=password")
  cnxn = pyodbc.connect("DSN=dsnname;UID=user;PWD=password")

To connect to SQL Server directly (without a DSN), you must specify the server and database to connect to using SQL Server-specific keywords. Note that the braces are required around the driver name.

  cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=server;DATABASE=database;UID=user;PWD=password)

Module Description Variables

version
The pyodbc version as a string in the format major.minor.revision.
apilevel
The string constant '2.0' indicating this module supports DB API level 2.0.
lowercase
A Boolean that controls whether column names in result rows are lowercased. This can be changed any time and affects queries executed after the change. The default is False. This can be useful when database columns have inconsistent capitalization.
pooling
A Boolean indicating whether connection pooling is enabled. This is a global (HENV) setting, so it can only be modified before the first connection is made. The default is True, which enables ODBC connection pooling.
threadsafety
The integer 1, indicating that threads may share the module but not connections. Note that connections and cursors may be used by different threads, just not at the same time.
qmark
The string constant "qmark" to indicate parameters are identified using question marks.

DB API Type Functions

The DB API defines a set of functions that convert from well-known types to data types required by the database module. If your code does not need to be portable between database modules (if you will only use pyodbc), you do not need to use these.

Date(year,month,day), DateFromTicks(ticks)
Both of these return a datetime.date instance.
Time(hour,minute,second), TimeFromTicks(ticks)
Both of these return a datetime.time instance.
Timestamp(year,month,day,hour,minute,second), TimestampFromTicks(ticks)
Both of these return a datetime.datetime instance.
DATETIME
Set to the datetime.datetime type. This is not entirely accurate since dates and times actually use two different classes, datetime.date and datetime.time, but there is no way to specify this.
STRING
Set to the string type.
NUMBER
Set to the float type. This is not entirely accurate since the module uses different types of numbers for different ODBC data types. Instead of using this, simply pass int, float, double, or decimal objects.
ROWID
Set to the int type.
Binary(string)
Returns a buffer instance.
BINARY
Set to the buffer type.

Module Constants

The following ODBC constants are defined. They only used with ODBC specific functions such as Cursor.tables.

Connection Objects

autocommit

False if the connection is in manual-commit mode (the default), which is the mode described by the DB API. True if the connection is in auto-commit mode. This can be set using the autocommit keyword in the connection function or can be changed by setting this attribute.

searchesc

The search pattern escape character used to escape '%' and '_' in search patterns, as returned by SQLGetInfo(SQL_SEARCH_PATTERN_ESCAPE). The value is driver specific.

execute(sql, [params])

This is a new method (not in the DB API) that creates a new Cursor object and returns Cursor.execute(...). See Cursor.execute for a description of the parameters.

  for results in cnxn.execute("select user_id from tmp"):
      print results.user_id

Since a new Cursor is created by each call, do not use when executing multiple statements in a row.

close()

Close the connection now (rather than whenever __del__ is called). The connection will be unusable from this point forward; a ProgrammingError exception will be raised if any operation is attempted with the connection. The same applies to all cursor objects trying to use the connection. Note that closing a connection without committing the changes first will cause an implicit rollback to be performed.

commit()

Commit any pending transaction to the database.

Note that Connections do not (yet) support autocommit; Connection.commit() must be called or changes will be rolled back when the connection is closed.

rollback()

Causes the the database to roll back to the start of any pending transaction.

cursor()

Return a new Cursor object using the connection.

getinfo(infotype)

Calls SQLGetInfo, passing infotype and returns the result as a Boolean, string, integer, or long value. The return type is determined by infotype.

The infotype value should be one of the following constants, defined in the pyodbc module. The table below shows the data type returned. See SQLGetInfo for the meaning of each constant.

ConstantReturn Type
SQL_ACCESSIBLE_PROCEDURESTrue or False
SQL_ACCESSIBLE_TABLESTrue or False
SQL_ACTIVE_ENVIRONMENTSint
SQL_AGGREGATE_FUNCTIONSint or long
SQL_ALTER_DOMAINint or long
SQL_ALTER_TABLEint or long
SQL_ASYNC_MODEint or long
SQL_BATCH_ROW_COUNTint or long
SQL_BATCH_SUPPORTint or long
SQL_BOOKMARK_PERSISTENCEint or long
SQL_CATALOG_LOCATIONint
SQL_CATALOG_NAMETrue or False
SQL_CATALOG_NAME_SEPARATORstring
SQL_CATALOG_TERMstring
SQL_CATALOG_USAGEint or long
SQL_COLLATION_SEQstring
SQL_COLUMN_ALIASTrue or False
SQL_CONCAT_NULL_BEHAVIORint
SQL_CONVERT_FUNCTIONSint or long
SQL_CONVERT_VARCHARint or long
SQL_CORRELATION_NAMEint
SQL_CREATE_ASSERTIONint or long
SQL_CREATE_CHARACTER_SETint or long
SQL_CREATE_COLLATIONint or long
SQL_CREATE_DOMAINint or long
SQL_CREATE_SCHEMAint or long
SQL_CREATE_TABLEint or long
SQL_CREATE_TRANSLATIONint or long
SQL_CREATE_VIEWint or long
SQL_CURSOR_COMMIT_BEHAVIORint
SQL_CURSOR_ROLLBACK_BEHAVIORint
SQL_DATABASE_NAMEstring
SQL_DATA_SOURCE_NAMEstring
SQL_DATA_SOURCE_READ_ONLYTrue or False
SQL_DATETIME_LITERALSint or long
SQL_DBMS_NAMEstring
SQL_DBMS_VERstring
SQL_DDL_INDEXint or long
SQL_DEFAULT_TXN_ISOLATIONint or long
SQL_DESCRIBE_PARAMETERTrue or False
SQL_DM_VERstring
SQL_DRIVER_HDESCint or long
SQL_DRIVER_HENVint or long
SQL_DRIVER_HLIBint or long
SQL_DRIVER_HSTMTint or long
SQL_DRIVER_NAMEstring
SQL_DRIVER_ODBC_VERstring
SQL_DRIVER_VERstring
SQL_DROP_ASSERTIONint or long
SQL_DROP_CHARACTER_SETint or long
SQL_DROP_COLLATIONint or long
SQL_DROP_DOMAINint or long
SQL_DROP_SCHEMAint or long
SQL_DROP_TABLEint or long
SQL_DROP_TRANSLATIONint or long
SQL_DROP_VIEWint or long
SQL_DYNAMIC_CURSOR_ATTRIBUTES1int or long
SQL_DYNAMIC_CURSOR_ATTRIBUTES2int or long
SQL_EXPRESSIONS_IN_ORDERBYTrue or False
SQL_FILE_USAGEint
SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1int or long
SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2int or long
SQL_GETDATA_EXTENSIONSint or long
SQL_GROUP_BYint
SQL_IDENTIFIER_CASEint
SQL_IDENTIFIER_QUOTE_CHARstring
SQL_INDEX_KEYWORDSint or long
SQL_INFO_SCHEMA_VIEWSint or long
SQL_INSERT_STATEMENTint or long
SQL_INTEGRITYTrue or False
SQL_KEYSET_CURSOR_ATTRIBUTES1int or long
SQL_KEYSET_CURSOR_ATTRIBUTES2int or long
SQL_KEYWORDSstring
SQL_LIKE_ESCAPE_CLAUSETrue or False
SQL_MAX_ASYNC_CONCURRENT_STATEMENTSint or long
SQL_MAX_BINARY_LITERAL_LENint or long
SQL_MAX_CATALOG_NAME_LENint
SQL_MAX_CHAR_LITERAL_LENint or long
SQL_MAX_COLUMNS_IN_GROUP_BYint
SQL_MAX_COLUMNS_IN_INDEXint
SQL_MAX_COLUMNS_IN_ORDER_BYint
SQL_MAX_COLUMNS_IN_SELECTint
SQL_MAX_COLUMNS_IN_TABLEint
SQL_MAX_COLUMN_NAME_LENint
SQL_MAX_CONCURRENT_ACTIVITIESint
SQL_MAX_CURSOR_NAME_LENint
SQL_MAX_DRIVER_CONNECTIONSint
SQL_MAX_IDENTIFIER_LENint
SQL_MAX_INDEX_SIZEint or long
SQL_MAX_PROCEDURE_NAME_LENint
SQL_MAX_ROW_SIZEint or long
SQL_MAX_ROW_SIZE_INCLUDES_LONGTrue or False
SQL_MAX_SCHEMA_NAME_LENint
SQL_MAX_STATEMENT_LENint or long
SQL_MAX_TABLES_IN_SELECTint
SQL_MAX_TABLE_NAME_LENint
SQL_MAX_USER_NAME_LENint
SQL_MULTIPLE_ACTIVE_TXNTrue or False
SQL_MULT_RESULT_SETSTrue or False
SQL_NEED_LONG_DATA_LENTrue or False
SQL_NON_NULLABLE_COLUMNSint
SQL_NULL_COLLATIONint
SQL_NUMERIC_FUNCTIONSint or long
SQL_ODBC_INTERFACE_CONFORMANCEint or long
SQL_ODBC_VERstring
SQL_OJ_CAPABILITIESint or long
SQL_ORDER_BY_COLUMNS_IN_SELECTTrue or False
SQL_PARAM_ARRAY_ROW_COUNTSint or long
SQL_PARAM_ARRAY_SELECTSint or long
SQL_PROCEDURESTrue or False
SQL_PROCEDURE_TERMstring
SQL_QUOTED_IDENTIFIER_CASEint
SQL_ROW_UPDATESTrue or False
SQL_SCHEMA_TERMstring
SQL_SCHEMA_USAGEint or long
SQL_SCROLL_OPTIONSint or long
SQL_SEARCH_PATTERN_ESCAPEstring
SQL_SERVER_NAMEstring
SQL_SPECIAL_CHARACTERSstring
SQL_SQL92_DATETIME_FUNCTIONSint or long
SQL_SQL92_FOREIGN_KEY_DELETE_RULEint or long
SQL_SQL92_FOREIGN_KEY_UPDATE_RULEint or long
SQL_SQL92_GRANTint or long
SQL_SQL92_NUMERIC_VALUE_FUNCTIONSint or long
SQL_SQL92_PREDICATESint or long
SQL_SQL92_RELATIONAL_JOIN_OPERATORSint or long
SQL_SQL92_REVOKEint or long
SQL_SQL92_ROW_VALUE_CONSTRUCTORint or long
SQL_SQL92_STRING_FUNCTIONSint or long
SQL_SQL92_VALUE_EXPRESSIONSint or long
SQL_SQL_CONFORMANCEint or long
SQL_STANDARD_CLI_CONFORMANCEint or long
SQL_STATIC_CURSOR_ATTRIBUTES1int or long
SQL_STATIC_CURSOR_ATTRIBUTES2int or long
SQL_STRING_FUNCTIONSint or long
SQL_SUBQUERIESint or long
SQL_SYSTEM_FUNCTIONSint or long
SQL_TABLE_TERMstring
SQL_TIMEDATE_ADD_INTERVALSint or long
SQL_TIMEDATE_DIFF_INTERVALSint or long
SQL_TIMEDATE_FUNCTIONSint or long
SQL_TXN_CAPABLEint
SQL_TXN_ISOLATION_OPTIONint or long
SQL_UNIONint or long
SQL_USER_NAMEstring
SQL_XOPEN_CLI_YEARstring

Cursor Objects

These objects represent a database cursor, which is used to manage the context of a fetch operation. Cursors created from the same connection are not isolated, i.e., any changes done to the database by a cursor are immediately visible by the other cursors.

description

This read-only attribute is a sequence of 7-item sequences. Each of these sequences contains information describing one result column: (name, type_code, display_size, internal_size, precision, scale, null_ok). pyodbc only provides values for name, type_code, internal_size, and null_ok. The other values are set to None. This attribute will be None for operations that do not return rows or if the cursor has not had an operation invoked via the executeXXX() method yet. The type_code member is the class type used to create the Python objects when reading rows. For example, a varchar column's type will be str. The complete list of types supported is listed in the Data Types section.

rowcount

This is always -1.

callproc(procname[,parameters])

This is not yet supported.

close()

Close the cursor now (rather than whenever __del__ is called). The cursor will be unusable from this point forward; a ProgrammingError exception will be raised if any operation is attempted with the cursor.

execute(sql [,parameters])

Prepare and execute SQL. Parameters may be passed as a sequence, as specified by the DB API, or as individual parameters.

  # standard
  cursor.execute("select a from tbl where b=? and c=?", (x, y))

  # pyodbc extension
  cursor.execute("select a from tbl where b=? and c=?", x, y)

The DB API specification does not specify the return value of this method. Cursors in pyodbc return different things based on the SQL statement executed. Select statements return the Cursor object itself to allow more compact code such as putting the execute method into for loops or appending fetchone or fetchall:

  for row in cursor.execute("select album_id, photo_id from photos"):
      print row.album_id, row.photo_id
  
  row = cursor.execute("select count(*) from tmp").fetchone()
  
  rows = cursor.execute("select * from tmp").fetchall()

Update and delete statements return the number of rows affected:

  count = cursor.execute("update photos set processed=1 where user_id=1")

  count = cursor.execute("delete from photos where user_id=1")

All other statements return None.

executemany(sql, seq_of_parameters)

Prepare a database operation (query or command) and then execute it against all parameter sequences or mappings found in the sequence seq_of_parameters. This method returns None.

fetchone()

Fetch the next row of a query result set, returning a single Row, or None when no more data is available.

A ProgrammingError exception is raised if the previous call to executeXXX() did not produce any result set or no call was issued yet.

  cursor.execute("select user_name from photos where user_id=?", userid)
  row = cursor.fetchone()
  if row:
      print row.user_name

nextset, setinputsizes, setoutputsize

These are optional in the API and are not supported.

fetchmany([size=cursor.arraysize])

Fetch the next set of rows of a query result, returning a list of Rows. An empty list is returned when no more rows are available.

The number of rows to fetch per call is specified by the parameter. If it is not given, the cursor's arraysize, which defaults to 1, determines the number of rows to be fetched. If this is not possible due to the specified number of rows not being available, fewer rows may be returned.

A ProgrammingError exception is raised if the previous call to executeXXX() did not produce any result set or no call was issued yet.

fetchall()

Fetch all remaining rows of a query result, returning them as a list of Rows. Since this reads all rows into memory, it should not be used if there are a lot of rows. Consider iterating over the rows instead.

A ProgrammingError exception is raised if the previous call to executeXXX() did not produce any result set or no call was issued yet.

  cursor.execute("select photo_id from photos where user_id=1")
  rows = cursor.fetchall()
  for row in rows:
      print row.user_name

__iter__, next

These methods allow a cursor to be used in a for loop, returning a single Row for each iteration. This allows all rows to be visited easily.

  cursor.execute("select photo_id from photos where user_id=1")
  for row in cursor:
      print row.photo_id

tables(table=None, catalog=None, schema=None, tableType=None)

Executes SQLTables and creates a results set of tables defined in the data source. Returns the Cursor.

The table, catalog, and schema interpret the '_' and '%' characters as wildcards. The escape character is driver specific, so use Connection.searchescape.

Each row has the following columns. See the SQLTables documentation for more information.

  1. table_cat: The catalog name.
  2. table_schem: The schema name.
  3. table_name: The table name.
  4. table_type: One of 'TABLE', 'VIEW', SYSTEM TABLE', 'GLOBAL TEMPORARY' 'LOCAL TEMPORARY', 'ALIAS', 'SYNONYM', or a data source-specific type name.
  for row in cursor.tables():
      print row.table_name

columns(table=None, catalog=None, schema=None, column=None)

Creates a results set of column names in specified tables by executing the ODBC SQLColumns function. Each row fetched has the following columns:

  1. table_cat
  2. table_schem
  3. table_name
  4. column_name
  5. data_type
  6. type_name
  7. column_size
  8. buffer_length
  9. decimal_digits
  10. num_prec_radix
  11. nullable
  12. remarks
  13. column_def
  14. sql_data_type
  15. sql_datetime_sub
  16. char_octet_length
  17. ordinal_position
  18. is_nullable: One of SQL_NULLABLE, SQL_NO_NULLS, SQL_NULLS_UNKNOWN.

statistics(table, catalog=None, schema=None, unique=False, quick=True)

Creates a results set of statistics about a single table and the indexes associated with the table by executing SQLStatistics.
unique
If True, only unique indexes are retured. Otherwise all indexes are returned.
quick
If True, CARDINALITY and PAGES are returned only if they are readily available from the server

Each row fetched has the following columns:

  1. table_cat
  2. table_schem
  3. table_name
  4. non_unique
  5. index_qualifier
  6. index_name
  7. type
  8. ordinal_position
  9. column_name
  10. asc_or_desc
  11. cardinality
  12. pages
  13. filter_condition

rowIdColumns(table, catalog=None, schema=None, nullable=True)

Executes SQLSpecialColumns with SQL_BEST_ROWID which creates a result set of columns that uniquely identify a row. Returns the Cursor object. Each row fetched has the following columns.

  1. scope: One of SQL_SCOPE_CURROW, SQL_SCOPE_TRANSACTION, or SQL_SCOPE_SESSION
  2. column_name
  3. data_type: The ODBC SQL data type constant (e.g. SQL_CHAR)
  4. type_name
  5. column_size
  6. buffer_length
  7. decimal_digits
  8. pseudo_column: One of SQL_PC_UNKNOWN, SQL_PC_NOT_PSEUDO, SQL_PC_PSEUDO

rowVerColumns(table, catalog=None, schema=None, nullable=True)

Executes SQLSpecialColumns with SQL_ROWVER which creates a result set of columns that are automatically updated when any value in the row is updated. Returns the Cursor object. Each row fetched has the following columns.

  1. scope: One of SQL_SCOPE_CURROW, SQL_SCOPE_TRANSACTION, or SQL_SCOPE_SESSION
  2. column_name
  3. data_type: The ODBC SQL data type constant (e.g. SQL_CHAR)
  4. type_name
  5. column_size
  6. buffer_length
  7. decimal_digits
  8. pseudo_column: One of SQL_PC_UNKNOWN, SQL_PC_NOT_PSEUDO, SQL_PC_PSEUDO

primaryKeys(table, catalog=None, schema=None)

Creates a results set of column names that make up the primary key for a table by executing the SQLPrimaryKeys function. Each row fetched has the following columns:

  1. table_cat
  2. table_schem
  3. table_name
  4. column_name
  5. key_seq
  6. pk_name

foreignKeys(table=None, catalog=None, schema=None, foreignTable=None, foreignCatalog=None, foreignSchema=None)

Executes the SQLForeignKeys function and creates a results set of column names that are foreign keys in the specified table (columns in the specified table that refer to primary keys in other tables) or foreign keys in other tables that refer to the primary key in the specified table. Each row fetched has the following columns:

  1. pktable_cat
  2. pktable_schem
  3. pktable_name
  4. pkcolumn_name
  5. fktable_cat
  6. fktable_schem
  7. fktable_name
  8. fkcolumn_name
  9. key_seq
  10. update_rule
  11. delete_rule
  12. fk_name
  13. pk_name
  14. deferrability

procedures(procedure=None, catalog=None, schema=None)

Executes SQLProcedures and creates a result set of information about the procedures in the data source. Each row fetched has the following columns:

  1. procedure_cat
  2. procedure_schem
  3. procedure_name
  4. num_input_params
  5. num_output_params
  6. num_result_sets
  7. remarks
  8. procedure_type

getTypeInfo(sqlType=None)

Executes SQLGetTypeInfo a creates a result set with information about the specified data type or all data types supported by the ODBC driver if not specified. Each row fetched has the following columns:

  1. type_name
  2. data_type
  3. column_size
  4. literal_prefix
  5. literal_suffix
  6. create_params
  7. nullable
  8. case_sensitive
  9. searchable
  10. unsigned_attribute
  11. fixed_prec_scale
  12. auto_unique_value
  13. local_type_name
  14. minimum_scale
  15. maximum_scale
  16. sql_data_type
  17. sql_datetime_sub
  18. num_prec_radix
  19. interval_precision

Row Objects

cursor_description

The column metadata from Cursor.description is also accessible from Row objects as the cursor_description attribute. This is convenient when Rows are used as ad-hoc data structures and are passed to other functions that need the metadata; now the Cursor does not need to be passed with them.

row = cursor.execute("select name, account_id from persons").fetchone()
column_names = [ t[0] for t in row.cursor_description ]

Accessing Values

The DB API specifies that results must be tuple-like, so columns are normally accessed by indexing into the sequence (e.g. row[0]) and pyodbc supports this. However, columns can also be accessed by name:

cursor.execute("select album_id, photo_id from photos where user_id=1")
row = cursor.fetchone()
print row.album_id, row.photo_id 
print row[0], row[1] # same as above, but less readable

This makes the code easier to maintain when modifying SQL, more readable, and allows rows to be used where a custom class might otherwise be used. All rows from a single execute share the same dictionary of column names, so using Row objects to hold a large result set may also use less memory than creating a object for each row.

The SQL "as" keyword allows the name of a column in the result set to be specified. This is useful if a column name has a spaces or if there is no name:

cursor.execute("select count(*) as photo_count from photos where user_id=1")
row = cursor.fetchone()
print row.photo_count

Rows Are Mutable

Though SQL is very powerful, values sometimes need to be modified before they can be used. Rows allow their values to be replaced, which makes Rows even more convenient ad-hoc dat structures.

# Replace a datetime in each row with one that has a time zone.
rows = cursor.fetchall()
for row in rows:
  row.start_date = row.start_date.astimezone(tz)

Note that only existing columns can be replaced; new columns cannot be added to rows. If you want to add a value that doesn't exist in the database, add a NULL to the select statement as a placeholder:

row = cursor.execute("select name, NULL as account_id from persons").fetchone()
row.account_id = 1

Data Types

The following table shows the ODBC data types supported and the Python type used to represent values. None is always used for NULL values.

ODBCPython
char, varchar, longvarchar, GUID string
wchar, wvarchar, wlongvarchar unicode
smallint, integer, tinyint int
bigint long
decimal, numeric decimal
real, float, double double
date datetime.date
time datetime.time
timestamp datetime.datetime
bit bool
binary, varbinary, longvarbinary buffer

Errors

When an error occurs, the type of exception raised is based on the SQLSTATE.

SQLSTATE Exception Class
0A000 NotSupportedError
22xxx DataError
23xxx IntegrityError
40002 IntegrityError
24xxx, 25xxx, 42xxx Programming Error
All Others DatabaseError

Catalog Functions

Most of the ODBC catalog functions are available as methods on Cursor objects. The results are presented as SELECT results in rows that are fetched normally. Refer to Microsoft's ODBC documentation for details of how to use each function.

cnxn   = pyodbc.connect(...)
cursor = cnxn.cursor()
for row in cursor.tables():
    print row.table_name

Some of the parameters, such as table in Cursor.tables (SQLTables) accept search patterns. In these parameters, the underscore character (_) is represents a single-character wildcard and the percent character (%) represents any sequence of zero or more characters. To include these characters as literals, precede them with the escape character Connection.searchesc. (The escape character is driver dependent.)

ODBC Function Method Description
SQLTables Cursor.tables Returns a list of table, catalog, or schema names, and table types.
SQLColumns Cursor.columns Returns a list of column names in specified tables.
SQLStatistics Cursor.statistics Returns a list of statistics about a single table and the indexes associated with the table.
SQLSpecialColumns Cursor.rowIdColumns Returns a list of columns that uniquely identify a row.
SQLSpecialColumns Cursor.rowVerColumns Returns a list of columns that are automatically updated any any value in the row is updated.
SQLPrimaryKeys Cursor.primaryKeys Returns a list of column names that make up the primary key for a table.
SQLForeignKeys Cursor.foreignKeys Returns a list of column names that are foreign keys in the specified table (columns in the specified table that refer to primary keys in other tables) or foreign keys in other tables that refer to the primary key in the specified table.
SQLProcedures Cursor.procedures Returns information about the procedures in the data source.
SQLGetTypeInfo Cursor.getTypeInfo Returns a information about the specified data type or all data types supported by the driver.

SourceForge.net Logo