Skip to content
brunocybersecPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

DataBase

Português (pt-BR) · English


Português (pt-BR)

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.

Estrutura do projeto

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 executar CreateDatabase.py e não faz parte do repositório.

Banco de dados

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).

Requisitos

  • Python 3.x
  • Biblioteca padrão sqlite3 (inclusa no Python)

Não há dependências externas.

Como usar

1. Criar o banco de dados

Execute na raiz do projeto:

python CreateDatabase.py

O script lê Users.sql, cria Users.db e exibe o total de usuários inseridos.

2. Consultar usuários (menu interativo)

python SearchForUsers.py

Opções disponíveis:

  1. Buscar por nome
  2. Buscar por sobrenome
  3. Buscar por idade
  4. Buscar por status (Active / Unactive)
  5. Listar todos os usuários
  6. Sair

3. Contar usuários

python count.py

Exibe a quantidade total de registros na tabela users.

Módulos

db.py

Centraliza a conexão com o banco através da função get_connection(), reutilizada por SearchForUsers.py.

CreateDatabase.py

Script de inicialização que executa o conteúdo de Users.sql via executescript e valida a criação com um SELECT COUNT(*).

SearchForUsers.py

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.

count.py

Utilitário simples que imprime o resultado de SELECT COUNT(*) FROM users.


English

Python study project for user management with SQLite. The repository includes scripts to create the database, query records, and utilities for connection and counting.

Project structure

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.db file is generated locally when running CreateDatabase.py and is not part of the repository.

Database

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).

Requirements

  • Python 3.x
  • Standard library sqlite3 (included with Python)

No external dependencies.

Usage

1. Create the database

Run from the project root:

python CreateDatabase.py

The script reads Users.sql, creates Users.db, and displays the total number of inserted users.

2. Query users (interactive menu)

python SearchForUsers.py

Available options:

  1. Search by name
  2. Search by surname
  3. Search by age
  4. Search by status (Active / Unactive)
  5. Show all users
  6. Exit

3. Count users

python count.py

Displays the total number of records in the users table.

Modules

db.py

Centralizes the database connection through the get_connection() function, reused by SearchForUsers.py.

CreateDatabase.py

Initialization script that runs the contents of Users.sql via executescript and validates creation with a SELECT COUNT(*).

SearchForUsers.py

Command-line application with a loop menu. Name and surname searches use LIKE (partial match); age and status use exact match.

count.py

Simple utility that prints the result of SELECT COUNT(*) FROM users.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages