Code Monkey home page Code Monkey logo

Comments (2)

coleifer avatar coleifer commented on June 5, 2024

Was this closed for a particular reason? Is this bug legit?

from unqlite-python.

ivansabik avatar ivansabik commented on June 5, 2024

Hey Charles, this bug is legit, you can try to reproduce it with db and instructions above. Seems I cannot add any records to that db and first time it opens, detects older records in length. However I closed it since I took a different approach and it worked just fine so it is not something stopping me now from moving on, maybe db got corrupt?

I am building a db using HTTP calls and their JSON responses. The file db turned out to be around 45 mbs and what I did that worked was instantiating, opening and closing db for each HTTP response. When I used a single db instance and 1 close() at the end of the for loop or no close() at all is when I got my db corrupted:

for i, cajero_json in enumerate(cajeros_json):
    db = UnQLite('cajeros.db')
    db.open()
    cajero = {}
    cajero['id'] = cajero_json['id']
    cajero['clave_institucion'] = cajero_json['cb']
    cajero['lat'] = cajero_json['l']['lat']
    cajero['lon'] = cajero_json['l']['lng']
    cajero['nombre_institucion'] = NOMBRES[cajero['clave_institucion']]
    try:
        if not db.exists(cajero['id']):
            url_cajero = CAJERO_URL + '?id=' + str(cajero['id']) + '&banco=' + str(cajero['clave_institucion'])
            cajero_json = requests.get(url_cajero).json()['contenido']
            cajero['cp'] = str(cajero_json['cp'])
            cajero['horario'] = cajero_json['hs']
            cajero['direccion'] = cajero_json['d']
            cajero['actualizacion'] = str(datetime.datetime.now())
            db[cajero['id']] = cajero
    except UnicodeEncodeError:
        print 'UnicodeEncodeError'
        print cajero
        pass
    finally:
        db.close()

By this just confirm also that the file size has nothing to do, right now with above script I built a 45 mb db without any trouble

from unqlite-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.