I'm using Pandas with latest sqlalchemy (1.4.36
) to query a MS SQL DB, using the following Python 3.10.3
[Win] snippet:
import pandas as pd #
from sqlalchemy import create_engine, event
from sqlalchemy.engine.url import URL
# ...
def get_table_columns():SQLA = 'SELECT TABLE_NAME,COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME LIKE \'pa%\' ORDER BY TABLE_NAME;' # Use pandas for getting named table & columnsconn_str = set_db_info()conn_url = URL.create("mssql+pyodbc", query={"odbc_connect": conn_str})engine = create_engine(conn_url)df = pd.read_sql(SQLA, engine)# Permanently changes the pandas settingspd.set_option('display.max_rows', None)pd.set_option('display.max_columns', None)print(df)return df
However, this only prints the first 292 rows, and not all of the entire 2351 rows. Using REPL, I can check this with:
>>> z = get_table_columns()
>>> zTABLE_NAME COLUMN_NAME
0 paacc accesscd
... # <-- I added these
292 paapepi piapeheadat>>> z.count()
TABLE_NAME 2351
COLUMN_NAME 2351
dtype: int64>>> z.shape[0]
2351>>> z.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 2351 entries, 0 to 2350
Data columns (total 2 columns):# Column Non-Null Count Dtype
--- ------ -------------- -----0 TABLE_NAME 2351 non-null object1 COLUMN_NAME 2351 non-null object
dtypes: object(2)
memory usage: 36.9+ KB
Q: What is going on, and why can't I print/show all the rows?