sqlite - Python's sqlite3 module not consolidating my database changes -



attempting populate database latlon weather data future consultation. doing via sqlite3 python module.

at moment, able create table (a resulting .db file visible after program execution). able consult rows after insertion, i'm sure cursor.execute lines working.

unfortunately, after program execution, upon consulting database "select * table" statement, nothing appears (even though same command worked beforehand, while program executed). in fact, when dumping sqlite3 file, create statement.

what wrong? no errors or warnings.

the code itself:

#!/usr/bin/python import sys import numpy netcdf4 import dataset import sqlite3  # config variables. n = 0 e = -30 s = -30 w = -60  ncfile = sys.argv[1]; ncdata = dataset(ncfile,'r',format='netcdf4')  sst = ncdata.variables['sea_surface_temperature'] lat = ncdata.variables['lat'] lon = ncdata.variables['lon']  # data reshaping. lat = lat[:] lon = lon[:] sst = sst[:]  c_lat = numpy.argwhere((lat <= n) & (lat >= s)) c_lon = numpy.argwhere((lon <= e) & (lon >= w))  conn = sqlite3.connect('sst.db') c = conn.cursor()  # create database table. c.execute("""create table current(lat real, lon real, sst real)""")  sqlite3.register_adapter(numpy.float64, float) sqlite3.register_adapter(numpy.float32, float) lati in c_lat:     loni in c_lon:         latn = lati[0]         lonn = loni[0]         lat_db = lat[latn]         lon_db = lon[lonn]         sst_db = sst[0,lonn][latn]          values = (lat_db,lon_db,sst_db)         if type(sst_db) != numpy.float64:             continue          c.execute("insert current values(?,?,?)",values)  # test if data inserted. (it is!) c.execute("select * current") print c.fetchall() 


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -