What is the Python equivalent for JDBC DatabaseMetaData?

What is the Python equivalent for DatabaseMetaData

+3
source share
2 answers

This is not an answer to python; I don’t really know if the Python data drivers have such things. But perhaps this information will help.

ANSI SQL-92 and SQL-99 require the INFORMATION_SCHEMA schema , which stores information about tables in a directory.

The metadata you are looking for can be obtained with a request for views in this schema.

eg:

select column_name, is_nullable, data_type, character_maximum_length as maxlen 
from information_schema.columns 
where table_name = 'Products'

Not all databases implement this part of the standard. Oracle, for example, is not.

, , , ​​.

Microsoft SQL Server Information_Schema, , SQL Server, . [CatalogName].dbo.sysobjects [CatalogName].dbo.sysolumns. , . :

select * from [CatalogName].dbo.syscolumns 
where id = 
    (Select id from [CatalogName].dbo.sysobjects where name = 'Products')

Oracle ALL_TAB_COLUMNS :

select column_name, data_type, data_length, data_precision, data_scale
from ALL_TAB_COLUMNS
where table_name = 'EMP';

, , db, ODBC - db, , .

+6

ODBC , pyodbc, http://code.google.com/p/pyodbc/wiki/Features. Pyodbc , SQLTables, JDBC getTables. JDBC ODBC .

0

Source: https://habr.com/ru/post/1708579/


All Articles