liveBook · Manning

Data type

As explained in Build Python Web Apps with Streamlit

A data type specifies the kind of value that a database column can store and the operations applicable to that value.

A data type specifies what kind of value a column can store. Choosing types is part of defining a table’s schema: for example, a username can be a VARCHAR string, while a creation time can be a timestamp. section 8.2.4 section 8.2.1

CREATE TABLE haikus (
  haiku_id SERIAL PRIMARY KEY,
  created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP,
  author VARCHAR(100),
  text TEXT,
  FOREIGN KEY (author) REFERENCES users(username)
);

This table definition uses SERIAL for an auto-incrementing integer, TIMESTAMPTZ for a timestamp with time-zone information, and TEXT for haiku content. section 8.2.4

Types affect how values fit into columns:

  • VARCHAR(100) stores strings up to 100 characters; longer values cause an error. section 8.2.4
  • TIMESTAMPTZ can use CURRENT_TIMESTAMP as a default when an inserted row omits a value. section 8.2.4
  • Pandas uses dtypes such as object and float64; it can also use string[pyarrow] and double[pyarrow]. section 6.2.1

How Build Python Web Apps with Streamlit covers it

How deep it goes
Explains string limits, automatic integer values, and timestamp defaults, without detailing type internals.
Examples
Uses user and haiku table columns, plus sales-data columns reported as object or float64.
What it assumes
Builds from basic relational table, row, and column definitions rather than assuming database-schema knowledge.
What you can do after
Apply data types by defining PostgreSQL table columns with appropriate string, integer, or timestamp types.
How it connects
Links data types to SQL, relational database schemas, pandas, NumPy, and Apache Arrow.

Also explained in

Compare how 18 books explain data type →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Python Web Apps with Streamlit. The section links point to the parts of the book it draws on.