Complete Reference with Copy-Paste Examples
Part of The Direct Path to Linux Ubuntu
— free for all students and developers.
SQL is the language of every relational database — MySQL, PostgreSQL, SQLite, Oracle, SQL Server. One language, every platform.
Window functions, CTEs, GROUP BY with HAVING — SQL processes millions of rows in milliseconds with a single declarative statement.
BEGIN/COMMIT/ROLLBACK ensure data integrity — bank transfers, inventory, anything where partial updates would cause corruption.
sqlite3 is built into Python. psycopg2 connects to PostgreSQL. SQLAlchemy provides ORM for any database — no SQL string juggling.
Run SQL:
# SQLite (built-in, no install) sqlite3 database.db # interactive shell sqlite3 database.db < schema.sql # run SQL file python3 script.py # python3 sqlite3 built-in # PostgreSQL sudo apt install postgresql postgresql-client sudo systemctl start postgresql psql -U postgres # interactive shell psql -U user -d mydb -f file.sql # MySQL/MariaDB sudo apt install mysql-server sudo systemctl start mysql mysql -u root -p # interactive shell mysql -u user -p mydb < file.sql # Python pip install psycopg2-binary # PostgreSQL pip install mysql-connector-python # MySQL pip install sqlalchemy # ORM for all databases