Browse Source

updates

master
F2256342 - Daniel de Oliveira Carvalho 1 year ago
parent
commit
d7f1d195ad
  1. 3
      design-notes.txt
  2. 77
      etl.py
  3. 495
      pdfScrape.ipynb

3
design-notes.txt

@ -15,6 +15,7 @@ so
and so on
should we control wether it's paid or not?
probably not as the idea is to have no manual conciliation of transactions
probably not as the idea is to have no manual conciliation of credit card transactions
should we control initial installment, and last separately?
probably not, the transaction registry itself is proof of existence.

77
etl.py

@ -0,0 +1,77 @@
def read_cc_full_invoice():
import re
from datetime import date, datetime
import locale
locale.setlocale(locale.LC_ALL, 'pt_BR.UTF-8')
# Open the text file
with open('OUROCARD_VISA_INFINITE-Ago_24.txt', 'r', encoding='latin') as file:
# Read the contents of the file
contents = file.readlines()
# Define the regex patterns
dan_pattern = r'1 - DANIEL.*'
iza_pattern = r'4 - IZABELY.*'
line_pattern = r'\d{2}\.\d{2}\.\d{4}.{23}.{14}.{2}\s*\d+,\d{2}\s*\d+,\d{2}'
line_group_pattern = r'(\d{2})\.(\d{2})\.(\d{4})(.{23})(.{14})(.{2})(\s*\d+,\d{2})(\s*\d+,\d{2})'
# Lists
list_dan = []
list_iza = []
current_list = None
insert_bulk = []
# Iterate all lines
for line in contents:
line = line.strip()
if re.match(dan_pattern, line):
current_list = 'list_dan'
print('found Dan')
elif re.match(iza_pattern, line):
current_list = 'list_iza'
print('found Iza')
else:
if re.match(line_pattern, line):
if current_list == 'list_dan':
print("dan", line)
list_dan.append(line)
if current_list == 'list_iza':
print("iza", line)
list_iza.append(line)
print('list_dan - tuples for insert')
for item in list_dan:
match = re.search(line_group_pattern, item)
tTdate = str(date(int(match.group(3)), int(match.group(2)), int(match.group(1))))
tAccount = 1
tMemo = match.group(4)
tCity = match.group(5)
tCountry = match.group(6)
tOutflow = match.group(7).strip().replace(',', '.')
tInflow = match.group(8).strip().replace(',', '.')
tOwner = 1
tInstallments = 1
tCreated = str(datetime.now(tz=None))
tUpdated = None
insert_bulk.append(( tTdate, tAccount, tMemo, tCity, tCountry, tOutflow, tInflow, tOwner, tInstallments, tCreated, tUpdated ))
print('list_dan - tuples for insert')
for item in list_iza:
match = re.search(line_group_pattern, item)
tTdate = str(date(int(match.group(3)), int(match.group(2)), int(match.group(1))))
tAccount = 1
tMemo = match.group(4)
tCity = match.group(5)
tCountry = match.group(6)
tOutflow = match.group(7).strip().replace(',', '.')
tInflow = match.group(8).strip().replace(',', '.')
tOwner = 2
tInstallments = 1
tCreated = str(datetime.now(tz=None))
tUpdated = None
insert_bulk.append(( tTdate, tAccount, tMemo, tCity, tCountry, tOutflow, tInflow, tOwner, tInstallments, tCreated, tUpdated ))
return insert_bulk

495
pdfScrape.ipynb

@ -104,39 +104,9 @@
},
{
"cell_type": "code",
"execution_count": 48,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Lines under TABLEA:\n",
"UNGA\n",
"DATA\n",
"DATA\n",
"DATA\n",
"DATA\n",
"DATA\n",
"DATA\n",
"DATA\n",
"DATA\n",
"DATA\n",
"\n",
"Lines under TABLEB:\n",
"BUNGA\n",
"DELTA\n",
"DELTA\n",
"DELTA\n",
"DELTA\n",
"DELTA\n",
"DELTA\n",
"DELTA\n",
"DELTA\n",
"DELTA\n"
]
}
],
"outputs": [],
"source": [
"# Open the text file\n",
"with open('table-test.txt', 'r') as file:\n",
@ -178,136 +148,15 @@
},
{
"cell_type": "code",
"execution_count": 50,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"found Dan\n",
"dan 15.07.2024NEW EMPAR EMPREENDIMENTCORUMBA DE GO BR 10,00 0,00\n",
"dan 14.07.2024NAZO SUSHI BAR BRASILIA BR 446,22 0,00\n",
"dan 18.07.2024IFD*IFOOD.COM AGENCIA DOsasco BR 12,90 0,00\n",
"dan 19.07.2024IFD*RC MELO COMERCIO D BRASILIA BR 138,30 0,00\n",
"dan 21.07.2024GRUPO FARTURA DE HORTI BRASILIA BR 105,79 0,00\n",
"dan 20.07.2024IFD*JL COMERCIO VAREJISBRASILIA BR 134,70 0,00\n",
"dan 22.07.2024MURAKAMI BRASILIA BR 55,90 0,00\n",
"dan 22.07.2024ZP *CANTINAGOODLANCHEV Brasilia BR 8,40 0,00\n",
"dan 23.07.2024CANTINA E CIA BRASILIA BR 10,00 0,00\n",
"dan 25.07.2024CANTINA E CIA BRASILIA BR 3,50 0,00\n",
"dan 24.07.2024IFD*NFE COMERCIO DE ALIBRASILIA BR 101,89 0,00\n",
"dan 27.07.2024BENITA PANINOTECA BRASILIA BR 156,80 0,00\n",
"dan 26.07.2024IFD*BSQUARE PIZZA BURGEBRASILIA BR 123,99 0,00\n",
"dan 04.08.2024IFD*RC MELO COMERCIO DEBRASILIA BR 103,29 0,00\n",
"dan 06.08.2024CANTINA E CIA BRASILIA BR 6,00 0,00\n",
"dan 06.08.2024ZP *CANTINAGOODLANCHEV Brasilia BR 210,00 0,00\n",
"dan 07.08.2024IFD*BSQUARE PIZZA BURGEBRASILIA BR 232,99 0,00\n",
"dan 22.07.2024DROGASIL 2067 BRASILIA BR 204,99 0,00\n",
"dan 22.07.2024REDE BRASIL DRUGSTORE BRASILIA BR 26,74 0,00\n",
"dan 10.08.2024PAGUE MENOS 1225 BRASILIA BR 406,30 0,00\n",
"dan 13.07.2024PAG*EduardoMeireles AGUAS LINDAS BR 14,00 0,00\n",
"dan 13.07.2024MR JOHN BARBEARIA LTDA BRASILIA BR 60,00 0,00\n",
"dan 18.07.2024NETFLIX.COM SAO PAULO BR 44,90 0,00\n",
"dan 19.07.2024PAG*FolhaDeSPaulo SAO PAULO BR 29,90 0,00\n",
"dan 19.07.2024IFD*CR EXPRESS Osasco BR 10,00 0,00\n",
"dan 22.07.2024APPLE.COM/BILL SAO PAULO BR 97,90 0,00\n",
"dan 22.07.2024MERCADOLIVRE*MERCADOLIVOSASCO BR 444,40 0,00\n",
"dan 25.07.2024MP*5PRODUTOS OSASCO BR 308,93 0,00\n",
"dan 25.07.2024MERCADOLIVRE*SABORESDAMOSASCO BR 258,00 0,00\n",
"dan 27.07.2024MP*MELIMAIS OSASCO BR 17,99 0,00\n",
"dan 27.07.2024Wellhub Gympass BR GympSao Paulo BR 399,90 0,00\n",
"dan 26.07.2024IFD*CR EXPRESS Osasco BR 10,00 0,00\n",
"dan 29.07.2024MG LAVA JATO BRASILIA BR 100,00 0,00\n",
"dan 29.07.2024MERCADOLIVRE*GLDECOR OSASCO BR 50,75 0,00\n",
"dan 01.08.2024MR JOHN BARBEARIA LTDA BRASILIA BR 54,00 0,00\n",
"dan 04.08.2024APPLE.COM/BILL SAO PAULO BR 54,90 0,00\n",
"dan 04.08.2024IFD*SCORPIONS EXPRESS Osasco BR 10,00 0,00\n",
"dan 08.08.2024CASCOL COMBUSTIVEIS BRASILIA BR 239,37 0,00\n",
"dan 07.08.2024IFD*GRAN LOG EXPRESS Osasco BR 10,00 0,00\n",
"dan 09.08.2024SUPERAUTOR C*Supe NITEROI BR 247,86 0,00\n",
"dan 09.08.2024UBER* TRIP WWW.UBER.COM. BR 30,89 0,00\n",
"dan 09.08.2024UBER *TRIP HELP.UBER.COSAO PAULO BR 10,00 0,00\n",
"dan 09.08.2024UBER * PENDING SAO PAULO BR 27,93 0,00\n",
"dan 09.08.2024UBER *TRIP HELP.UBER.COSAO PAULO BR 5,00 0,00\n",
"dan 15.07.2024VELOE BARUERI BR 22,26 0,00\n",
"dan 19.07.2024POUSADA PIRENEUS RESOR PIRENOPOLIS BR 179,21 0,00\n",
"dan 13.07.2024DL*GOOGLE YouTub SAO PAULO BR 41,90 0,00\n",
"dan 16.07.2024STEAMGAMES.COM 42595229912-1844160 WA 24,00 0,00\n",
"dan 16.07.2024IOF - COMPRA NO EXTERIOR 0,26 0,00\n",
"dan 16.07.2024STEAM PURCHASE SEATTLE DE 127,19 0,00\n",
"dan 18.07.2024IOF - COMPRA NO EXTERIOR 1,39 0,00\n",
"dan 22.07.2024PAG*XsollaGames Sao Paulo BR 26,99 0,00\n",
"dan 11.04.2024PRODUTOS GLOB PARC 04/12 RIO DE JANEIBR 44,90 0,00\n",
"dan 15.01.2024MP*MUNDODOSCO PARC 07/10 SAO PAULO BR 159,90 0,00\n",
"dan 17.05.2024PAG*Folhadesp PARC 03/06 Sao Paulo BR 109,60 0,00\n",
"dan 17.10.2023BIANCHINI AUT PARC 10/10 BRASILIA BR 535,00 0,00\n",
"dan 27.05.2024PARC=112 BRAS PARC 03/12 BRASILIA BR 452,00 0,00\n",
"found Iza\n",
"iza 15.07.2024SALTO CORUMBA CORUMBA DE GO BR 163,85 0,00\n",
"iza 12.07.2024PG *TON MINHACANTINA BRASILIA BR 35,00 0,00\n",
"iza 12.07.2024PASTELARIA VICOSA IV BRASILIA BR 130,00 0,00\n",
"iza 12.07.2024PASTELARIA VICOSA IV BRASILIA BR 19,00 0,00\n",
"iza 13.07.2024CANTINA E CIA BRASILIA BR 4,50 0,00\n",
"iza 18.07.2024MERCADOLIVRE*3PRODUTOS OSASCO BR 362,28 0,00\n",
"iza 20.07.2024COFFEE BIKE CAFES ESPECBRASILIA BR 10,00 0,00\n",
"iza 19.07.2024IFD*ARCOS DOURADOS COMEBRASILIA BR 48,99 0,00\n",
"iza 22.07.2024RESTAURANTE FAROFINA BRASILIA BR 43,90 0,00\n",
"iza 23.07.2024PAG*DiogoLealPimenta BRASILIA BR 183,00 0,00\n",
"iza 28.07.2024TREVISO GALETERIA E P BRASILIA BR 200,20 0,00\n",
"iza 30.07.2024OLINDA COMIDA NORDESTI BRASILIA BR 66,45 0,00\n",
"iza 03.08.2024DULCE PATAGONIA BRASILIA BR 177,90 0,00\n",
"iza 03.08.2024HOT DOG CLUB BRASILIA BR 39,90 0,00\n",
"iza 04.08.2024RESTAURANTE SAO JOAO TERESINA BR 108,00 0,00\n",
"iza 04.08.2024GELATO E GRANO TERESINA BR 24,00 0,00\n",
"iza 05.08.2024F L L MELO LTDA SAO PAULO BR 63,00 0,00\n",
"iza 10.08.2024CREMERIA ITALIANA BRASILIA BR 49,00 0,00\n",
"iza 14.07.2024RITUARIA*Rituaria SAO PAULO BR 448,20 0,00\n",
"iza 24.07.2024BIOEXATA FARMACIA BRASILIA BR 73,70 0,00\n",
"iza 12.07.2024CASCOL COMBUSTIVEIS BRASILIA BR 297,86 0,00\n",
"iza 12.07.2024LIMBER SOFTWARE E CONS SAO LUIZ DO P BR 54,00 0,00\n",
"iza 13.07.2024PAG*EduardoMeireles AGUAS LINDAS BR 22,00 0,00\n",
"iza 13.07.2024PAG*EduardoMeireles AGUAS LINDAS BR 36,00 0,00\n",
"iza 13.07.2024PAG*CidaRommanel BRASILIA BR 30,00 0,00\n",
"iza 13.07.2024ALLPARK EMPREENDIMENTOSGoiania BR 6,00 0,00\n",
"iza 14.07.2024MERCADOLIVRE*CHINALINK OSASCO BR 445,89 0,00\n",
"iza 18.07.2024PG *S S MENDES COMERCI MOGI DAS CRUZ BR 150,12 0,00\n",
"iza 19.07.2024MERCADOLIVRE*3PRODUTOS OSASCO BR 276,52 0,00\n",
"iza 03.08.2024WOW*SALE COMERCIO E SE Brasilia BR 165,00 0,00\n",
"iza 07.08.2024PARENTELA PANIFICADORA BRASILIA BR 64,90 0,00\n",
"iza 08.08.2024FranciscoDeAssis BRASILIA BR 36,00 0,00\n",
"iza 09.08.2024BONNAPAN SEU DIA MAIS BRASILIA BR 23,08 0,00\n",
"iza 10.08.2024MP*BRILHODASARTE OSASCO BR 300,00 0,00\n",
"iza 11.07.2024CARREFOUR PL2 338 BRASILIA BR 83,17 0,00\n",
"iza 15.07.2024UBER * PENDING SAO PAULO BR 19,90 0,00\n",
"iza 22.07.2024UBER * PENDING SAO PAULO BR 8,98 0,00\n",
"iza 23.07.2024UBER* TRIP WWW.UBER.COM. BR 8,90 0,00\n",
"iza 24.07.2024UBER* TRIP WWW.UBER.COM. BR 8,98 0,00\n",
"iza 29.07.2024UBER * PENDING SAO PAULO BR 8,94 0,00\n",
"iza 30.07.2024UBER* TRIP WWW.UBER.COM. BR 8,94 0,00\n",
"iza 31.07.2024UBER* TRIP WWW.UBER.COM. BR 8,96 0,00\n",
"iza 06.08.2024UBER* TRIP WWW.UBER.COM. BR 8,99 0,00\n",
"iza 10.08.2024UBER* TRIP WWW.UBER.COM. BR 20,00 0,00\n",
"iza 10.08.2024UBER* TRIP WWW.UBER.COM. BR 9,42 0,00\n",
"iza 10.08.2024UBER * PENDING SAO PAULO BR 13,97 0,00\n",
"iza 12.07.2024CIDA REIS MODA FITNESS BRASILIA BR 300,00 0,00\n",
"iza 15.07.2024LANCHONETE SERRA RODO COCALZINHO DE BR 43,00 0,00\n",
"iza 09.08.2024HOTEL GOYA P*hote RIO DE JANEIR BR 424,20 0,00\n",
"iza 17.01.2024BRASILIA EMPR PARC 07/12 BRASILIA BR 599,00 0,00\n",
"iza 07.01.2024PG *B4A GLAMB PARC 08/12 SAO PAULO BR 74,90 0,00\n"
]
}
],
"outputs": [],
"source": [
"import re\n",
"from datetime import date, datetime\n",
"from decimal import *\n",
"import locale\n",
"\n",
"# export LC_ALL=\"pt_BR.UTF-8\"\n",
"# export LC_CTYPE=\"pt_BR.UTF-8\"\n",
"locale.setlocale(locale.LC_ALL, 'pt_BR.UTF-8')\n",
"getcontext().prec = 2\n",
"\n",
"# Open the text file\n",
"with open('OUROCARD_VISA_INFINITE-Ago_24.txt', 'r', encoding='latin') as file:\n",
@ -330,7 +179,6 @@
"# Iterate all lines\n",
"for line in contents:\n",
" line = line.strip()\n",
" # print(line)\n",
" if re.match(dan_pattern, line):\n",
" current_list = 'list_dan'\n",
" print('found Dan')\n",
@ -338,57 +186,45 @@
" current_list = 'list_iza'\n",
" print('found Iza')\n",
" else:\n",
" # print(line)\n",
" if re.match(line_pattern, line):\n",
" if current_list == 'list_dan':\n",
" print(\"dan\", line)\n",
" # list_dan.append(line)\n",
" list_dan.append(line)\n",
" if current_list == 'list_iza':\n",
" print(\"iza\", line)\n",
" # list_iza.append(line)\n",
" list_iza.append(line)\n",
"\n",
"# # Print the results\n",
"# print('Lines under list_dan:')\n",
"# for item in list_dan:\n",
"# # print(item)\n",
"# match = re.search(line_group_pattern, item)\n",
"# # print(match.group(1))\n",
"# # build tuples for inserting\n",
"# tTdate = str(date(int(match.group(3)), int(match.group(2)), int(match.group(1))))\n",
"# tAccount = 1\n",
"# tMemo = match.group(4)\n",
"# tCity = match.group(5)\n",
"# tCountry = match.group(6)\n",
"# tOutflow = match.group(7).strip().replace(',', '.')\n",
"# tInflow = match.group(8).strip().replace(',', '.')\n",
"# tOwner = 1\n",
"# tInstallments = None\n",
"# tCreated = str(datetime.now(tz=None))\n",
"# tUpdated = None\n",
"# insert_bulk.append(( tTdate, tAccount, tMemo, tCity, tCountry, tOutflow, tInflow, tOwner, tInstallments, tCreated, tUpdated ))\n",
"# print(insert_bulk)\n",
"print('list_dan - tuples for insert')\n",
"for item in list_dan:\n",
" match = re.search(line_group_pattern, item)\n",
" tTdate = str(date(int(match.group(3)), int(match.group(2)), int(match.group(1))))\n",
" tAccount = 1\n",
" tMemo = match.group(4)\n",
" tCity = match.group(5)\n",
" tCountry = match.group(6)\n",
" tOutflow = match.group(7).strip().replace(',', '.')\n",
" tInflow = match.group(8).strip().replace(',', '.')\n",
" tOwner = 1\n",
" tInstallments = 1\n",
" tCreated = str(datetime.now(tz=None))\n",
" tUpdated = None\n",
" insert_bulk.append(( tTdate, tAccount, tMemo, tCity, tCountry, tOutflow, tInflow, tOwner, tInstallments, tCreated, tUpdated ))\n",
"\n",
"\n",
"# print('\\nLines under list_iza:')\n",
"# for item in list_iza:\n",
"# # print(item)\n",
"# match = re.search(line_group_pattern, item)\n",
"# # print(match.group(1))\n",
"# # build tuples for inserting\n",
"# tTdate = str(date(int(match.group(3)), int(match.group(2)), int(match.group(1))))\n",
"# tAccount = 1\n",
"# tMemo = match.group(4)\n",
"# tCity = match.group(5)\n",
"# tCountry = match.group(6)\n",
"# tOutflow = match.group(7).strip().replace(',', '.')\n",
"# tInflow = match.group(8).strip().replace(',', '.')\n",
"# tOwner = 2\n",
"# tInstallments = None\n",
"# tCreation = str(datetime.now(tz=None))\n",
"# tUpdated = None\n",
"# insert_bulk.append(( tTdate, tAccount, tMemo, tCity, tCountry, tOutflow, tInflow, tOwner, tInstallments, tCreation, tUpdated ))\n",
"# print(insert_bulk)\n",
"\n"
"print('list_dan - tuples for insert')\n",
"for item in list_iza:\n",
" match = re.search(line_group_pattern, item)\n",
" tTdate = str(date(int(match.group(3)), int(match.group(2)), int(match.group(1))))\n",
" tAccount = 1\n",
" tMemo = match.group(4)\n",
" tCity = match.group(5)\n",
" tCountry = match.group(6)\n",
" tOutflow = match.group(7).strip().replace(',', '.')\n",
" tInflow = match.group(8).strip().replace(',', '.')\n",
" tOwner = 2\n",
" tInstallments = 1\n",
" tCreated = str(datetime.now(tz=None))\n",
" tUpdated = None\n",
" insert_bulk.append(( tTdate, tAccount, tMemo, tCity, tCountry, tOutflow, tInflow, tOwner, tInstallments, tCreated, tUpdated ))\n"
]
},
{
@ -402,29 +238,250 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 45,
"metadata": {},
"outputs": [],
"source": [
"def create_lists():\n",
" import re\n",
"\n",
" # Open the text file\n",
" with open('OUROCARD_VISA_INFINITE-Ago_24.txt', 'r', encoding='latin') as file:\n",
" # Read the contents of the file\n",
" contents = file.readlines()\n",
"\n",
" # Define the regex patterns\n",
" dan_pattern = r'1 - DANIEL.*'\n",
" iza_pattern = r'4 - IZABELY.*'\n",
" line_pattern = r'\\d{2}\\.\\d{2}\\.\\d{4}.{23}.{14}.{2}\\s*\\d+,\\d{2}\\s*\\d+,\\d{2}'\n",
"\n",
" # Lists\n",
" list_dan = []\n",
" list_iza = []\n",
" current_list = None\n",
"\n",
" # Iterate all lines\n",
" for line in contents:\n",
" line = line.strip()\n",
" if re.match(dan_pattern, line):\n",
" current_list = 'list_dan'\n",
" elif re.match(iza_pattern, line):\n",
" current_list = 'list_iza'\n",
" else:\n",
" if re.match(line_pattern, line):\n",
" if current_list == 'list_dan':\n",
" list_dan.append(line)\n",
" if current_list == 'list_iza':\n",
" list_iza.append(line)\n",
" \n",
" return [list_dan, list_iza]"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [],
"source": [
"def build_insert(lists: list[list, list], account: int, owner: int):\n",
" from datetime import date, datetime\n",
"\n",
" insert_bulk = []\n",
" line_group_pattern = r'(\\d{2})\\.(\\d{2})\\.(\\d{4})(.{23})(.{14})(.{2})(\\s*\\d+,\\d{2})(\\s*\\d+,\\d{2})'\n",
"\n",
" for batch in lists:\n",
" for item in batch:\n",
" match = re.search(line_group_pattern, item)\n",
" tTdate = str(date(int(match.group(3)), int(match.group(2)), int(match.group(1))))\n",
" tAccount = account\n",
" tMemo = match.group(4)\n",
" tCity = match.group(5)\n",
" tCountry = match.group(6)\n",
" tOutflow = match.group(7).strip().replace(',', '.')\n",
" tInflow = match.group(8).strip().replace(',', '.')\n",
" tOwner = owner\n",
" tInstallments = 1\n",
" tCreated = str(datetime.now(tz=None))\n",
" tUpdated = None\n",
" insert_bulk.append(( tTdate, tAccount, tMemo, tCity, tCountry, tOutflow, tInflow, tOwner, tInstallments, tCreated, tUpdated ))\n",
" \n",
" return insert_bulk"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [],
"source": [
"# from getpass import getpass\n",
"from mysql.connector import connect, Error\n",
"def db_insert(insert_bulk: list[tuple]):\n",
" from mysql.connector import connect, Error\n",
"\n",
"try:\n",
" with connect(\n",
" host='localhost',\n",
" user='root',\n",
" password='pleasehashapasswordomg',\n",
" database='default'\n",
" ) as connection:\n",
" print(\"CONNECTED!\", connection)\n",
" with connection.cursor() as cursor:\n",
" cursor.executemany(insert_query, insert_bulk)\n",
" connection.commit()\n",
" print(\"DONE!\")\n",
"except Error as e:\n",
" print(e)\n",
"finally:\n",
" connection.close()\n"
" try:\n",
" with connect(\n",
" host='localhost',\n",
" user='root',\n",
" password='pleasehashapasswordomg',\n",
" database='default'\n",
" ) as connection:\n",
" print(\"CONNECTED!\", connection)\n",
" with connection.cursor() as cursor:\n",
" cursor.executemany(insert_query, insert_bulk)\n",
" connection.commit()\n",
" print(\"DONE!\")\n",
" except Error as e:\n",
" print(e)\n",
" finally:\n",
" connection.close()\n"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CONNECTED! <mysql.connector.connection_cext.CMySQLConnection object at 0x79c990b31430>\n",
"DONE!\n"
]
}
],
"source": [
"db_insert(\n",
" build_insert(\n",
" create_lists(), 1, 1\n",
" )\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 57,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"NEW EMPAR EMPREENDIMENT\n",
"NAZO SUSHI BAR \n",
"IFD*IFOOD.COM AGENCIA D\n",
"IFD*RC MELO COMERCIO D \n",
"GRUPO FARTURA DE HORTI \n",
"IFD*JL COMERCIO VAREJIS\n",
"MURAKAMI \n",
"ZP *CANTINAGOODLANCHEV \n",
"CANTINA E CIA \n",
"CANTINA E CIA \n",
"IFD*NFE COMERCIO DE ALI\n",
"BENITA PANINOTECA \n",
"IFD*BSQUARE PIZZA BURGE\n",
"IFD*RC MELO COMERCIO DE\n",
"CANTINA E CIA \n",
"ZP *CANTINAGOODLANCHEV \n",
"IFD*BSQUARE PIZZA BURGE\n",
"DROGASIL 2067 \n",
"REDE BRASIL DRUGSTORE \n",
"PAGUE MENOS 1225 \n",
"PAG*EduardoMeireles \n",
"MR JOHN BARBEARIA LTDA \n",
"NETFLIX.COM \n",
"PAG*FolhaDeSPaulo \n",
"IFD*CR EXPRESS \n",
"APPLE.COM/BILL \n",
"MERCADOLIVRE*MERCADOLIV\n",
"MP*5PRODUTOS \n",
"MERCADOLIVRE*SABORESDAM\n",
"MP*MELIMAIS \n",
"Wellhub Gympass BR Gymp\n",
"IFD*CR EXPRESS \n",
"MG LAVA JATO \n",
"MERCADOLIVRE*GLDECOR \n",
"MR JOHN BARBEARIA LTDA \n",
"APPLE.COM/BILL \n",
"IFD*SCORPIONS EXPRESS \n",
"CASCOL COMBUSTIVEIS \n",
"IFD*GRAN LOG EXPRESS \n",
"SUPERAUTOR C*Supe \n",
"UBER* TRIP \n",
"UBER *TRIP HELP.UBER.CO\n",
"UBER * PENDING \n",
"UBER *TRIP HELP.UBER.CO\n",
"VELOE \n",
"POUSADA PIRENEUS RESOR \n",
"DL*GOOGLE YouTub \n",
"STEAMGAMES.COM 42595229\n",
"IOF - COMPRA NO EXTERIO\n",
"STEAM PURCHASE \n",
"IOF - COMPRA NO EXTERIO\n",
"PAG*XsollaGames \n",
"PRODUTOS GLOB PARC 04/1\n",
"MP*MUNDODOSCO PARC 07/1\n",
"PAG*Folhadesp PARC 03/0\n",
"BIANCHINI AUT PARC 10/1\n",
"PARC=112 BRAS PARC 03/1\n",
"SALTO CORUMBA \n",
"PG *TON MINHACANTINA \n",
"PASTELARIA VICOSA IV \n",
"PASTELARIA VICOSA IV \n",
"CANTINA E CIA \n",
"MERCADOLIVRE*3PRODUTOS \n",
"COFFEE BIKE CAFES ESPEC\n",
"IFD*ARCOS DOURADOS COME\n",
"RESTAURANTE FAROFINA \n",
"PAG*DiogoLealPimenta \n",
"TREVISO GALETERIA E P \n",
"OLINDA COMIDA NORDESTI \n",
"DULCE PATAGONIA \n",
"HOT DOG CLUB \n",
"RESTAURANTE SAO JOAO \n",
"GELATO E GRANO \n",
"F L L MELO LTDA \n",
"CREMERIA ITALIANA \n",
"RITUARIA*Rituaria \n",
"BIOEXATA FARMACIA \n",
"CASCOL COMBUSTIVEIS \n",
"LIMBER SOFTWARE E CONS \n",
"PAG*EduardoMeireles \n",
"PAG*EduardoMeireles \n",
"PAG*CidaRommanel \n",
"ALLPARK EMPREENDIMENTOS\n",
"MERCADOLIVRE*CHINALINK \n",
"PG *S S MENDES COMERCI \n",
"MERCADOLIVRE*3PRODUTOS \n",
"WOW*SALE COMERCIO E SE \n",
"PARENTELA PANIFICADORA \n",
"FranciscoDeAssis \n",
"BONNAPAN SEU DIA MAIS \n",
"MP*BRILHODASARTE \n",
"CARREFOUR PL2 338 \n",
"UBER * PENDING \n",
"UBER * PENDING \n",
"UBER* TRIP \n",
"UBER* TRIP \n",
"UBER * PENDING \n",
"UBER* TRIP \n",
"UBER* TRIP \n",
"UBER* TRIP \n",
"UBER* TRIP \n",
"UBER* TRIP \n",
"UBER * PENDING \n",
"CIDA REIS MODA FITNESS \n",
"LANCHONETE SERRA RODO \n",
"HOTEL GOYA P*hote \n",
"BRASILIA EMPR PARC 07/1\n",
"PG *B4A GLAMB PARC 08/1\n"
]
}
],
"source": [
"tLists = build_insert(create_lists(), 1, 1)\n",
"for item in tLists:\n",
" print(item[2])\n",
" "
]
}
],

Loading…
Cancel
Save