[Flask] Store Data in a SQLite-Database with Flask

Corey Boyle coreybrett at gmail.com
Mon Nov 21 16:16:19 EST 2016


This is not related to Flask, but maybe you could use Zabbix Sender to send
your data to a Zabbix server for collection.

https://www.zabbix.com/documentation/3.0/manual/concepts/sender

On Nov 21, 2016 4:10 PM, "Anthony Ford" <ford.anthonyj at gmail.com> wrote:

> I created a similar system to monitor a series of Modbus enabled GPIO
> units (Acromag
> <https://www.acromag.com/catalog/318/ethernet-modbus-profibus-io/ethernet-io-modules/multi-function-io/busworks-900en-series> units).
> Flask is not well suited  to having a data logger within it.
>
> Flask is more of a User Interface, and is event based, meaning that
> nothing happens until the server (and therefore your Flask app) get a
> request from a browser. This means you can easily fetch the current state
> when someone wants it (i.e. a big "FETCH STATUS" button). However, if you
> need periodic monitoring (like I did), it is better to have a separate
> program that ONLY does the data logging.
>
> You can possibly get away with threading, and launching a separate thread
> from within your Flask app, but I personally think it's not worth the
> complexity.
>
> If you use a full database system (PostgreSQL is my go-to) instead of
> SQLite, it is easy to have the logger application dump into the database,
> while the Flask app reads from the Database.
>
> If you avoid using Flask-SQLAlchemy in favor of vanilla (or standard)
> SQLAlchemy, you can even share the database modules between the apps (via a
> common shared package, or just plain importing from one or the other).
>
> If desired, I can talk more about my approach, but unfortunately I can't
> share code, and sanitizing the code to be shareable would take a lot of
> work.
>
> Hope this helps!
>
> Anthony Ford,
> KF5IBN,
> ford.anthonyj at gmail.com
>
> On Sun, Nov 20, 2016 at 1:23 PM, Dmitry <d at ddipp.net> wrote:
>
>> Hello Andreas!
>>
>> Tell me - why do you need a flask?
>> Flask - web framework, and you have a function, framed by "@app.route" is
>> caused not through the web, and from the same program.
>> Try to remove the "@ app.route" to function.
>> Also, you will not be initialized "g.db". Think about why.
>>
>> 20.11.2016 21:23, Andreas Dorfner пишет:
>>
>> Hello everyone,
>>
>> I'm new to python and flask web development.
>> I have to realize a data logger using flask. By using another framework
>> called 'pymodbus', I get some data from
>> an energy meter and save that data to a variable called 'crv_data' (see
>> file attached). This part is working so far!
>>
>> The second part of the project contains the storage of 'crv_data' to a
>> SQLite-Database. For that, I'm using flask.
>> For creating a table with five columns, a file 'schema.sql' (also
>> attached) is included.
>>
>> If the file 'logger.py' is running, a database is produced with the
>> desired layout and some data in 'crv_data' is available.
>> But there is no data included in the database.
>>
>> I think there is an error in function 'add_entry()' (starting in line 72
>> of logger.py file), because if I call the function
>> in the infinite loop (line 103), the program stops running.
>> Maybe I have to say that I using Beaglebone Black with running Debian on
>> it.
>>
>> Does anybody have an idea, why the program doesn't work?
>> Many thanks,
>> Andreas
>>
>>
>> ---
>> Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
>> https://www.avast.com/antivirus
>>
>>
>> _______________________________________________
>> Flask mailing listFlask at python.orghttps://mail.python.org/mailman/listinfo/flask
>>
>>
>> --
>> Dmitry Podkovyrkin
>> email: d at ddipp.net
>>
>>
>> _______________________________________________
>> Flask mailing list
>> Flask at python.org
>> https://mail.python.org/mailman/listinfo/flask
>>
>>
>
> _______________________________________________
> Flask mailing list
> Flask at python.org
> https://mail.python.org/mailman/listinfo/flask
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20161121/fc05d37a/attachment-0001.html>


More information about the Flask mailing list