Easy DB Help File

From OpenCircuits
Revision as of 08:32, 2 December 2019 by Russ hensel (talk | contribs) (→‎Why)
Jump to navigation Jump to search

This is the Help "file" for the Python Application whose main page is: *Python Easy DataBase Project - OpenCircuits


Help file for Easy DataBase application ( Documentation for Ver7 ). You can also get a lot of information about how the program works by looking at the GUI and its explanation: Easy DB GUI Images.


Application Features

  • SmartPlug GUI Images.
  • Supports comma separated values ( csv ) output of data to text files.
  • Saves data to a sql lite database that you can use any way you wish.
  • Highly configurable.


Download and Install

There is really no install program. Currently the application is intended for those who have at least a little familiarity with Python coding and can just insert the downloaded code into their development environment and run it. Code at russ-hensel/Smart_plug Application For most of you it will not run due to dependency problems. You will need to add them. Pretty much read the error messages and install the missing code. I use Anaconda Spyder so my preferred tool is conda ( conda install pyHS100 ). If conda does not work or you do not use it use pip. pyHS100, a library for smart plugs is pretty likely to be missing ( pip install pyHS100) . Depending on your installation there may be more.

Much of the application is configurable through the parameter.py file, but the default should give you an application that runs, including a default database. You probably will not be able to talk to your smartplugs, because the parameters do need to be told what and where ( tcpip address ) they are.



How To:...

Some stuff is pretty obvious from the GUI, take a look at it as well as reading the material here SmartPlug GUI Images.

How do I?

  • Install: see section above.
  • Debug: see section below.
  • Edit the parameter file: *Change Parameters: Use the application button <Edit Parms> ( after configuring for your editor ) or any text editor suitable for Python ( no tabs ) on the file parameters.py. See also: The section below, Configuration Files For Python and SmartPlug GUI Images
  • Edit the log file: This is a standard python logging file. Useful for debugging and general tracking of the application. You can set the level of the logging using the parameter file.
  • Backup the database: Just make a copy of the database using your file manager. It is all in one file, but you can make multiple databases.
  • Quick Restart of the application: As perhaps after a parameter change. Use the <Restart> button. See also: SmartPlug GUI Images
  • Switch databases: Use browse control on GUI. Please do not change while db operations are active.
  • Get Help: Press the <Help> button. Depending on how it is setup in parameters.py you may see this page.
  • Work with text in message area: See buttons to the left of the area.
  • Create a database?
  • Create a table?
  • Select some data from a table?
  • Sort my data?
  • Choose a data format for output
  • Backup a database? Close the system, then use your file manager to make a copy of the database file.
  • export data to a spreadsheet
  • delete some data
  • how do I know if there has been an error
  • how to I find and fix errors
  • How do I install the software.
  • I created a new table and inserted data, but I would like to redo it to fix issues what should I do.
  • how do I drop a table
  • edit records
  • How do i fix a field name if the system complains.
  • How do I make up a valid column name.

Why

  • Why are the spaces in my column names missing? Spaces in column names are usually not allowed in SQL so the system changes n consecutive spaces to an under score.
  • What happened to the spaces at the beginning and end of my data? The system considers them mistakes, and removes them.
  • My data contained a # and something odd happened.
  • Why is there a column called ROW ID? It is built into sqllite, generally ignore it.
  • Why are all of the column names in lower case? The system does not like upper case column names so they are automatically changed to lower case.
  • What happens to blank input lines? They are ignored by the system.
  • What happens to comment lines? They are ignored by the system.



What if

  • I define a table that already exists ( option to ) drop and recreate.

How to Use the Parameter File

See: Configuration Files For Python You need a text editor suitable for .py files to manage the parameter file ( parameters.py ) This includes most text editors. I particularity like:

  • notepad++
  • geany

You can also use the editor that comes in many python development environments, the simplest of which may be Idle. But there are many many others. If you are reading this you probably have some experience.

Once you configure an editor in parameters.py you can edit from the <Edit Parms> in the GUI ( see below )

When editing there are couple of gotchas to watch out for.

  • Python cares about capitalization, use the capitalization indicated in the default files and the example code.
  • Python also cares a lot about how lines are indented. Do not change the indentation from the sample files, and always indent using spaces ( not tabs. most text editors will use spaces automatically for .py files, even if you use the tab key )

Editing of the parameters.py file

  • Edit so the program finds your devices.
    • See above in Download and Install
  • Enable your favorite editor to work with the application.
    • self.ex_editor = r"D:\apps\Notepad++\notepad++.exe" # use r" or the backslashes will not work, or you can use forward slashes instead they may be wrong but they work.
  • Lots of other settings:
    • Read the comments in parameters.py and change as desired. If a setting does not work let me know.
  • If you mess up.
    • Re download and get back to the original file.

Working With Database Files

  • Create a directory for your data and database -- application comes with defaults


  • Run database definition routine button wf1
      You need to name a database, application will default
      You also need your sample file input, start with the one from
      the step above.
      look at output.......



The GUI

see: Easy DB GUI Images

Debugging

There are several application outputs that may be useful for debugging.

  • Watch the GUI
  • Check the Python console.
  • Look at the python log file ( use the GUI button <Edit Log> ( specify your editor in parameters.py first ) or use your editor on the default name of the log file ...\smart_plug\smart_plug.py_log.

Most issues will probably be missing libraries, parameters.py issues, or just bugs in my code (email me ).


Links