Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mysql.connector.errors.ProgrammingError: Failed processing format-parameters;
- Python 'ndarray' cannot be converted to a MySQL type
- import sys
- import collections
- import os
- import netCDF4
- import calendar
- from netCDF4 import Dataset
- import mysql.connector
- from mysql.connector import errorcode
- table = 'rob-tabl'
- con = mysql.connector.connect(user='rob', password='xxxx',
- database=roby)
- cursor = con.cursor()
- smeData = "INSERT INTO `" + table + "` "
- .
- .
- .
- .
- .Here I define MYSQL columns
- .
- .
- .
- data_array = []
- for item in totfiles.items(): # loop on different netCDF files in a directory , but at the moment I had only one file
- nc = Dataset('filename', 'r')
- data1 = nc.variables['time'][:]
- data2 = nc.variables['microsec'][:]
- data3 = nc.variables['temperature'][:]
- data4 = nc.variables['humidity'][:]
- data5 = nc.variables['pressure'][:]
- data = data1 + data2 + data3 + data4 + data5
- data_array.append(data)
- print 'data_array: ', data_array
- cursor.execute(smeData, data_array)
- data_array = []
- for item in totfiles.items():
- nc = Dataset('filename', 'r')
- data1 = nc.variables['time'][:]
- data_array.append(data)
- print 'data_array: ', data_array
- cursor.execute(smeData, data_array)
- "One of your passed values could be of type numpy.float64 which is not recognized
- by the MySQL connector. Cast it to a genuine python float on populating the dict."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement