Skip to content

Commit

Permalink
Configurações conexão BD
Browse files Browse the repository at this point in the history
- Suporte para conexão ao banco de dados
- Criação de teste de conexão com select dos times
- Alteração no gitignore
  • Loading branch information
jpmondoni committed Feb 24, 2018
1 parent 1253081 commit 4e1c461
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,4 @@ ENV/
/site

# mypy
.mypy_cache/
Modulos/Times/select_team_mysql.py
.mypy_cache/
7 changes: 7 additions & 0 deletions Modulos/Times/database_conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mysql = {
'user': 'scott',
'password': 'password',
'host': '127.0.0.1',
'database': 'employees',
'raise_on_warnings': True,
}
15 changes: 15 additions & 0 deletions Modulos/Times/select_team_mysql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import mysql.connector
import database_conf as cfg

cnx = mysql.connector.connect(**cfg.mysql)

cursor = cnx.cursor()
query = ("SELECT team_number, team_name FROM teams")

cursor.execute(query)

for(team_number, team_name) in cursor:
print("{} -> {}".format(team_number, team_name))

cursor.close()
cnx.close()
2 changes: 1 addition & 1 deletion Modulos/Times/teams.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
DROP TABLE IF EXISTS `teams`;
CREATE TABLE `teams` (
`number` int(11) NOT NULL,
`team_number` int(11) NOT NULL,
`team_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`team_short_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
Expand Down

0 comments on commit 4e1c461

Please sign in to comment.