Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions exercicios/para-casa/bdsemana13.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "code",
"source": [
"import csv\n",
"import sqlite3\n"
],
"metadata": {
"id": "yWS_Qz5kW7-v"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"for entrada in entradas:\n",
" print(entrada)"
],
"metadata": {
"id": "tdcfXH55a-95"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"file = open(\"/content/drive/MyDrive/csv/data.csv\", encoding= 'UTF-8')\n",
"\n",
"conteudo = csv.reader(file)\n",
"\n",
"connection = sqlite3.connect(\"/content/drive/MyDrive/csv/data.csv\")\n",
"\n",
"cursor = connection.cursor()\n",
"\n",
"cursor.execute ('''CREATE TABLE IF NOT EXISTS Rank(\n",
"\n",
" Rank INT,\n",
" Time FLOAT,\n",
" Name VARCHAR,\n",
" Country VARCHAR,\n",
" Date of Birth DATE,\n",
" Place INT,\n",
" City VARCHAR,\n",
" Date DATE,\n",
" Gender VARCHAR,\n",
" Event VARCHAR\n",
"\n",
")''')\n",
"\n",
"inserir_conteudo = \"INSERT INTO Rank (Rank,Time, Name, Country, Date of Birth, Place, City, Date, Gender, Event)VALUES()\"\n",
"\n",
"cursor.executemany(inserir_conteudo, conteudo)\n",
"\n",
"selecionar_tudo = \"SELECT * FROM Rank\"\n",
"entradas = cursor.execute(selecionar_tudo).fetchall()"
],
"metadata": {
"id": "Ri_9cRFT9jpB"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"connection.commit()\n",
"connection.close()"
],
"metadata": {
"id": "zyD57b4VbBGT"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "Wcjwpjs_9iUT"
},
"execution_count": null,
"outputs": []
}
]
}
Loading