Editing Easy DB Help File

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
This is the Help "file" for the Python Application whose main page is: *'''[http://www.opencircuits.com/Python_Easy_DataBase_Project Python Easy DataBase Project - OpenCircuits ]'''.  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]]'''.
+
This is the Help "file" for the Python Application whose main page is: *'''[http://www.opencircuits.com/Python_Easy_DataBase_Project 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 =  
 
= Application Features =  
  
* '''[[Easy DB GUI Images]]'''.
+
*   '''[[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.
+
*Supports comma separated values ( csv ) output of data to text files.
* Highly configurable.
+
*Saves data to a sql lite database that you can use any way you wish.
* Some of the terminology used here is covered in '''[[Basic Database Terminology]]'''
+
*Highly configurable.
  
 +
 
= Download and Install =  
 
= 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 '''[https://gitlab.com/russhensel/easy_db Easy DB code]''' 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.  If conda does not work or you do not use it use pip.   
+
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 '''[https://github.com/russ-hensel/smart_plug/tree/master 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.
  
Much of the application is configurable through the parameter.py file, but the default may not give you an application that runs, including a default database.
+
 +
  
 
= How To:... =  
 
= How To:... =  
Line 67: Line 74:
  
 
=  How to Use the Parameter File =  
 
=  How to Use the Parameter File =  
* For general information see: [[Configuration Files For Python]].
+
See: [[Configuration Files For Python]]
* For detailed information read the file parameters.py.
 
 
 
 
 
 
You need a text editor suitable for .py files to manage the parameter file ( parameters.py )
 
You need a text editor suitable for .py files to manage the parameter file ( parameters.py )
This includes many text editors.  I particularity like:
+
This includes most text editors.  I particularity like:
  
 
*notepad++
 
*notepad++
Line 99: Line 103:
  
 
=  A Scenario/Use Case =
 
=  A Scenario/Use Case =
 
== The Goal ==
 
  
 
Lets start a new database of dogs names, their breed, and typical weight, then run a report of all the names
 
Lets start a new database of dogs names, their breed, and typical weight, then run a report of all the names
Line 106: Line 108:
 
delete all the records where the dogs name is Spike.
 
delete all the records where the dogs name is Spike.
  
== Make a New Database ==
+
Start the system, then press the button <Make Generic Input>
 
+
    this will make a generic input form, a template for
Now you need a database to keep this data ( and a place for the table named something like dogs ).
+
    defining a database table and its data.  The system will
You can use any database that is hanging around and does not already have a table called
+
    use your systems text editor to open the file.
dogs ( use the Database File: <Browse...> button to choose one or make a new one.
+
   
 
+
Save the file with a new name so it will not get overwritten the next time <Make Generic Input>
Lets do it the hard way and make a new one.  You could type in the name you want for the file
+
    is run.
but that can be tricky especially getting the path right, so lets pick one using the Database: file <Browse...>
 
button, then edit the name. For example:  I browse to:
 
 
 
    D:/Russ/0000/python00/python3/_projects/easy_db/people/people_database.db
 
 
 
which must exist ( since your browse to it ) and edit to
 
 
 
    D:/Russ/0000/python00/python3/_projects/easy_db/people/dog_database.db
 
       
 
note:  the old file will be erased, lets warn the user and get approval ??    not sure we make it yet, we should     
 
the file must not already exist ( remember we are making a new db ) but the path to it must
 
you may use your file manager to make new folders ( directories ) if you wish.
 
  
== Prepare Some Data ==
 
Start the system, then press the button in the form area <Make Generic Input>
 
this will make a generic input form, a template for
 
defining a database table and its data.  The system will
 
use your systems text editor to open the file.
 
   
 
Save the file with a new name so it will not get overwritten the next time <Make Generic Input> is run.
 
  
 
Now we will edit the file for your new set of data.
 
Now we will edit the file for your new set of data.
Note that the file is full of comments ( lines starting with # )
+
    Note that the file is full of comments ( lines starting with # )
* The purpose of the file is still insert, so do not change that
+
    The purpose of the file is still insert, so do not change that
* The name of the table should be changed to something like dogs  ( generic_table_name => dogs )  
+
    The name of the table should be changed to something like dogs  ( generic_table_name => dogs )  
*Now we come to the column or field names, change them for the dogs, something like:
+
    Now we come to the column or field names, change them for the dogs, something like:
 
 
 
         ( name_first:    => dog_name:
 
         ( name_first:    => dog_name:
 
           name_middle:  => breed:
 
           name_middle:  => breed:
 
           name_last:    => typical_weight: )
 
           name_last:    => typical_weight: )
* There are repeated records ( rows ) for this, get rid of the excess and make a bunch of sections so you have one section for each of the dogs you plan to enter. ( or make the sections as you go ).
+
    There are repeated records ( rows ) for this, get rid of the excess and make a bunch of
 +
    sections so you have one section for each of the dogs you plan to enter. ( or make the sections as you go )
 
      
 
      
* Enter your data, only one line per item of data.
+
Enter your data, only one line per item of data.
 
   
 
   
* When you are done your file should look like the generic file, but now specialized for dogs.
+
When you are done your file should look like the generic file, but now specialized for dogs.
  
* File it away ( remember its name )
+
File it away ( remember its name )
  
 +
Now you need a database to keep this data ( the table named something like dogs ).
 +
You can use any database that is hanging around and does not already have a table called
 +
dogs ( use the <Browse...> button to choose one or make a new one.
  
 +
Lets do it the hard way and make a new one.  You could type in the name you want for the file
 +
but that can be tricky especially getting the path right, so lets pick one using the Database file <Browse...>
 +
button, then edit the name.
 +
        example:  I browse to: D:/Russ/0000/python00/python3/_projects/easy_db/people/people_database.db
 +
        which must exist and edit to
 +
                              D:/Russ/0000/python00/python3/_projects/easy_db/people/dog_database.db
 +
       
 +
no the old file will be erased, lets warn the user and get approval ??    not sure we make it yet, we should     
 +
        the file must not already exist ( remember we are making a new db ) but the path to it must
 +
        you may use your file manager to make new folders ( directories ) if you wish.     
 +
 
Now for the input file <Browse...> to the file you just made.
 
Now for the input file <Browse...> to the file you just made.
 
         you can use the <Edit File> button to look at the file again if you wish.
 
         you can use the <Edit File> button to look at the file again if you wish.
Line 167: Line 164:
 
         Select the table from the drop down ( dogs ) Then press <Select All>
 
         Select the table from the drop down ( dogs ) Then press <Select All>
 
         Your text editor should open with the output.
 
         Your text editor should open with the output.
 +
       
 +
       
  
== Report/Output Data ==
 
  
= In Depth =
 
This revisits some material already covered but in more depth.  Perhaps in a, or many, separate pages but  here for now.
 
  
== Table Creation ==
 
  
=== Table and Column Name Rules ===
 
  
Much the same rules apply to both table and column names:
 
  
* Use lower case.
+
= Working With Database Files =
* No spaces in names, do not start with a number, generally avoid non alphebetic characterss ( except _ )
 
 
* Names do not contain spaces tabs or weird characters
 
 
* the "_" character may be used in place of a space to make a name that would otherwise be two_words.
 
* Certain words are used by the sql language and are reserved for that, you cannot use them for table or column
 
names, some will be caught by the system ( more will be added as we trip across them ).  They include: like, where, select delete.....
 
  
==== if you do not follow the guidelines then ====
+
* Create a directory for your data and database -- application comes with defaults
           
 
* the system may change your name to meet the guidelines ( excess spaces removed, spaces changed to underscore, case shifted to lower case.... ,
 
* you may get a helpful error message
 
*you may get odd unexpected results perhaps with an unhelpful error message or none at all.
 
  
    it takes a common form for lines in the systems files. These are of the
 
  
 
+
* 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.
== Output/Reporting ==
+
      look at output.......
Generally there are three aspects to output:
 
 
 
*What table and what columns from that table are used.
 
*What data is selected.
 
*What is the order of the data.
 
*What format is used for the data.
 
 
 
These are covered below.
 
 
 
=== Table and Columns ===
 
 
 
=== Selection Criteria ===
 
 
 
=== Sort Order ===
 
 
 
 
 
 
 
 
 
 
 
 
 
=== Output Formats ===
 
When running a query ( you could call it a report ) there are a variety of formats to choose between ( not including which columns.... which is part of Output Content ).  When you run a query the system tries to open the resulting file ( output is always to file, if you need printed output print the file ) in the approiapate viewer, often your text editor.
 
 
 
This list of formats may expand as I think of new options but as of now:
 
 
 
===== Table =====
 
 
 
Table is an ASCII sort of spreadsheet, each record is on a single line, | characters separate the columns.  Here is an example for the dogs scenario:
 
<pre>
 
#---------- file output from EasyDB Ver9:  2019_12_01.01
 
# sql =  SELECT ROWID, breed, dog_name, typical_weight FROM dogs  ORDER BY ROWID ASC
 
# select built from =
 
purpose:export
 
use_table: dogs
 
ROWID | breed | dog_n | typic
 
------------------------
 
1    | Poodl | Spike | 25 
 
2    | Wolf  | Mike  | 80 
 
3    | Sprin | Penny | 33 
 
4    | Mut  | Woof  | 200 
 
:======== eof footer ============
 
</pre>
 
 
 
This is a nice concise form of output as long as the output does not get wider than your printer or screen. If you really want the data in a spreadsheet then use CSV output which is
 
easy to import into most spreadsheets.
 
 
 
==== Input ====
 
Input format makes the output look just like a cleaned up version of the input that would be necessary to input the data.  One major difference is that the purpose is listed as export.  This stops you from using it as input by mistake, you have to change the purpose to insert.
 
 
 
<pre>
 
#---------- file output from EasyDB Ver9:  2019_12_01.01
 
# sql =  SELECT ROWID, breed, dog_name, typical_weight FROM dogs  ORDER BY ROWID ASC
 
purpose:export
 
use_table: dogs
 
:====================
 
ROWID:1
 
breed:Poodle
 
dog_name:Spike
 
typical_weight:25
 
:====================
 
ROWID:2
 
breed:Wolf
 
dog_name:Mike
 
typical_weight:80
 
:====================
 
ROWID:3
 
breed:Springer
 
dog_name:Penny
 
typical_weight:33
 
:====================
 
ROWID:4
 
breed:Mut
 
dog_name:Woof
 
typical_weight:200
 
:==================== eof footer ============
 
</pre>
 
 
 
==== PyLog ====
 
Here all the output is sent to the Python log file. The data will be mixed in with other logged information.
 
 
 
 
 
<pre>
 
2019-12-02 20:36:05,467 - App - DEBUG - sql =    SELECT ROWID, breed, dog_name, typical_weight FROM dogs  ORDER BY ROWID ASC
 
2019-12-02 20:36:05,468 - App - DEBUG - write_header()  self.col_names  ['ROWID', 'breed', 'dog_name', 'typical_weight']
 
2019-12-02 20:36:05,468 - App - Notice - #---------- SelectLogWriter output from EasyDB Ver9:  2019_12_01.01
 
self.table_info.sql =  SELECT ROWID, breed, dog_name, typical_weight FROM dogs  ORDER BY ROWID ASC
 
use_table:dogs
 
2019-12-02 20:36:05,469 - App - Notice - ============--------RowObject--------=====================
 
RowObject __str__()
 
edit_dict: {'ROWID': [1, None], 'breed': ['Poodle', None], 'dog_name': ['Spike', None], 'typical_weight': ['25', None]}
 
2019-12-02 20:36:05,469 - App - Notice - ============--------RowObject--------=====================
 
RowObject __str__()
 
edit_dict: {'ROWID': [2, None], 'breed': ['Wolf', None], 'dog_name': ['Mike', None], 'typical_weight': ['80', None]}
 
2019-12-02 20:36:05,469 - App - Notice - ============--------RowObject--------=====================
 
RowObject __str__()
 
edit_dict: {'ROWID': [3, None], 'breed': ['Springer', None], 'dog_name': ['Penny', None], 'typical_weight': ['33', None]}
 
2019-12-02 20:36:05,469 - App - Notice - ============--------RowObject--------=====================
 
RowObject __str__()
 
edit_dict: {'ROWID': [4, None], 'breed': ['Mut', None], 'dog_name': ['Woof', None], 'typical_weight': ['200', None]}
 
2019-12-02 20:36:05,469 - App - Notice - None
 
2019-12-02 20:36:05,469 - App - DEBUG - change_table_name =>>dogs<<
 
2019-12-02 20:36:05,473 - App - DEBUG - change_last_output_file_name easy_db.py_log
 
2019-12-02 20:36:05,487 - App - DEBUG - <<<<< Select complete <<<<<
 
</pre>
 
 
 
==== CSV ====
 
<pre>
 
ROWID breed dog_name typical_weight
 
1 Poodle Spike 25
 
2 Wolf Mike 80
 
3 Springer Penny 33
 
4 Mut Woof 200
 
 
 
</pre>
 
 
 
==== SQL ====
 
 
 
==== HTML ====
 
 
 
An HTML version of a table, much nicer to view than the ASCII version.
 
 
 
== Output Content ==
 
=== What Content ===
 
=== What Sort Order ===
 
  
 
= The GUI =
 
= The GUI =
Line 336: Line 193:
 
* Watch the GUI
 
* Watch the GUI
 
* Check the Python console.
 
* 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 ...\easy_db.py_log.
+
* 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 ).
 
  
[[Basic Database Terminology]]
+
Most issues will probably be missing libraries, parameters.py issues, or just bugs in my code (email me ).
  
 
<!-----------
 
<!-----------

Please note that all contributions to OpenCircuits may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see OpenCircuits:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)