Português (pt-BR) · English
Projeto de estudo em Python para gerenciamento de usuários com SQLite. O repositório contém scripts para criar o banco, consultar registros e utilitários de conexão e contagem.
DataBase/
├── CreateDatabase.py # Cria o banco Users.db a partir do script SQL
├── db.py # Módulo de conexão com o banco
├── SearchForUsers.py # Interface interativa de busca de usuários
├── count.py # Exibe a quantidade total de usuários
├── Users.sql # Schema e dados iniciais (50 usuários)
└── README.md
O arquivo
Users.dbé gerado localmente ao executarCreateDatabase.pye não faz parte do repositório.
O banco SQLite Users.db contém a tabela users com os seguintes campos:
| Coluna | Tipo | Descrição |
|---|---|---|
id |
INTEGER | Chave primária (auto incremento) |
nome |
TEXT | Nome do usuário |
sobrenome |
TEXT | Sobrenome |
idade |
INTEGER | Idade |
status |
TEXT | Active ou Unactive |
O arquivo Users.sql recria a tabela e insere 50 registros de exemplo (25 ativos e 25 inativos).
- Python 3.x
- Biblioteca padrão
sqlite3(inclusa no Python)
Não há dependências externas.
Execute na raiz do projeto:
python CreateDatabase.pyO script lê Users.sql, cria Users.db e exibe o total de usuários inseridos.
python SearchForUsers.pyOpções disponíveis:
- Buscar por nome
- Buscar por sobrenome
- Buscar por idade
- Buscar por status (
Active/Unactive) - Listar todos os usuários
- Sair
python count.pyExibe a quantidade total de registros na tabela users.
Centraliza a conexão com o banco através da função get_connection(), reutilizada por SearchForUsers.py.
Script de inicialização que executa o conteúdo de Users.sql via executescript e valida a criação com um SELECT COUNT(*).
Aplicação de linha de comando com menu em loop. As buscas por nome e sobrenome usam LIKE (correspondência parcial); idade e status usam correspondência exata.
Utilitário simples que imprime o resultado de SELECT COUNT(*) FROM users.
Python study project for user management with SQLite. The repository includes scripts to create the database, query records, and utilities for connection and counting.
DataBase/
├── CreateDatabase.py # Creates Users.db from the SQL script
├── db.py # Database connection module
├── SearchForUsers.py # Interactive user search interface
├── count.py # Displays the total number of users
├── Users.sql # Schema and seed data (50 users)
└── README.md
The
Users.dbfile is generated locally when runningCreateDatabase.pyand is not part of the repository.
The SQLite database Users.db contains the users table with the following columns:
| Column | Type | Description |
|---|---|---|
id |
INTEGER | Primary key (auto increment) |
nome |
TEXT | First name |
sobrenome |
TEXT | Last name |
idade |
INTEGER | Age |
status |
TEXT | Active or Unactive |
The Users.sql file recreates the table and inserts 50 sample records (25 active and 25 inactive).
- Python 3.x
- Standard library
sqlite3(included with Python)
No external dependencies.
Run from the project root:
python CreateDatabase.pyThe script reads Users.sql, creates Users.db, and displays the total number of inserted users.
python SearchForUsers.pyAvailable options:
- Search by name
- Search by surname
- Search by age
- Search by status (
Active/Unactive) - Show all users
- Exit
python count.pyDisplays the total number of records in the users table.
Centralizes the database connection through the get_connection() function, reused by SearchForUsers.py.
Initialization script that runs the contents of Users.sql via executescript and validates creation with a SELECT COUNT(*).
Command-line application with a loop menu. Name and surname searches use LIKE (partial match); age and status use exact match.
Simple utility that prints the result of SELECT COUNT(*) FROM users.