'Loss of information in mariadb
I am deploying mariadb with docker-compose and inserted a 270,000 row .csv file. Once I have it in the database I can work with it.
This file occupies 18 MB but when I restart the computer, the table still exists but its content does not. With other smaller tables I don't have this problem.
My docker compose is:
services:
mariadb:
container_name: mariadb
image: mariadb
restart: always
volumes:
- ./mariadb-data:/var/lib/mysql
environment:
MYSQL_DATABASE: 'db_prueba'
MYSQL_USER: 'admin'
MYSQL_PASSWORD: 'admin'
MARIADB_ROOT_PASSWORD: 'admin'
ports:
- 2022:3306
The error I get is:
2022-05-24 7:11:39 19 [ERROR] mariadbd: Cannot find record in 'df_munayapel_temp'.
How can I fix it?
My load code
# Defino el query con la sintaxis del insert
query = inspect.cleandoc(f''' INSERT INTO DF_MunAyapel_Temp ( datetime,lat,lon,weather_main, weather_description ,variable,value) VALUES ( '{datetime}','{lat}','{lon}', '{weather_main}', '{weather_description}','{variable}','{value}') ''')
# Ejecuto el query en MariaDB
cur.execute(query)
# Commit final para guardar las inserts, si hubo
db_manager.commit()
print('Commit')
# Cierro la conexion a la DB
print('Cerrando conexion a DB')
cur.close()
print('Fin ejecucion')
My Table is:
# conexion a MariaDb en docker.internal.host
db_manager = pymysql.connect(host='host.docker.internal', port=2022, user='root', passwd='admin', db='db_prueba')
print(db_manager)
cur = db_manager.cursor()
# Creación de la tabla
cur.execute(" CREATE TABLE `DF_MunAyapel_Temp` ( `datetime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `lat` double NOT NULL DEFAULT 0, `lon` double NOT NULL DEFAULT 0, `weather_main` VARCHAR(15) not null , `weather_description` VARCHAR(20) not null ,`variable` VARCHAR(15) not null , `value` double NOT NULL DEFAULT 0 ) ENGINE=CSV DEFAULT CHARSET=utf8mb4;")
records = cur.fetchall()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
