Monday, April 30, 2018

What happened to Windows Essentials?

It reached end of support couple of years ago, in January 2017. If you already have it, it will probably continue to work. It was a good application with lots of programs like:

Windows Movie Maker
Windows Live Mail
Windows Live Family Saftery and the
OneDrive desktop app.

You may still find web sites providing you copies, but they may be vectors for viruses and such.

How do you create a custom object in PowerShell?

One way to create a custom object is by using the New-Object cmdlet.

This cmdlet creates an instance of a .NET Framework or COM object.

Here is simple example:
-----------
$obj = New-Object PSObject -Property @{    
       F_Name = "Sam"    
       L_name="Luxton"
       Age = 50
       Email="S_Luxton@gmail.com"
       }

------------------------------
The image shows the response:


Custom_Object_0

You can 'parse' the object as shown in the next image.



Sunday, April 29, 2018

What is JerryScript?

No, it is not mispelled JavaScript. It is to (Internet of Things) IoT as JavaScript is to the Web. JerryScript is lightweight JavaScript to run on very constrained devices such as microcontrollers.

Just see how lightweight it is:

Only few kilobytes of RAM available to the engine (<64 br="" kb="" ram="">Constrained ROM space for the code of the engine (<200 kb="" p="" rom="">
JerryScript engine supports on-device, executio and provide access to periferals via JavaScript.

Presently it is supported officially only on Ubuntu 14.04+.

If you have the above go here and test drive:
http://jerryscript.net/getting-started/

Saturday, April 28, 2018

What is the most popular programming language presently?

Looking back at my previous post on programming language popularity C language was at the top with Java in the second place.


However according to a chart on this site  shown here, Java continues to be the king once in a while ceding the top place.


TiobeIndex2017.png

Note that Python is rising, probably because of its use in AI, BigData and Robotics.

Friday, April 27, 2018

Are there ODBC drivers for SQLite databases?

Yes. There are ODBC drivers.

Please go to this site  to download your ODBC driver for SQLite.

The current version are as described in my previous post. Download the one appropriate for you use:

LiteODBC_00

I downloaded the one shown here,


LiteODBC_0

You double click the executable show above to begin the installation.

Follow the wizard. Here are some screens shown for your guidance.


LiteODBC_1



LiteODBC_2

I chose the default folder.


LiteODBC_3


LiteODBC_4
As you may know Windows OS has two ODBC Data Source (x32) and (x64). You can verify that you find the driver in the (x64) version as shown here:


LiteODBC_5

Now you start using SQLite.

In the Install directory (in my case: C:\Program Files\SQLite ODBC Driver for Win64), you can find the ODBC Drivers for two versions,
SQLite 2.8.17 
 SQLite 3.22.0 .

How do you grow a succulent?

You do not know what a succulent is? No problem.

They are group of plants (more than 50 types) that store water in their leaves. The leaves look thick and may have slightly pointed end but their roots stay at the surface and do not go deep. They may be confused for cactus. They make easy to maintian plants that are grower friendly.

Here is a picture of one of them.

Actually we had one such plant and recently it died.



Driven by curiosity, I just took one of the leaves and it appeared to me that the leaf end had pinkish roots. The roots were small and I decided to stick the leaf into the soil and see what happens.

Lo and behold! the plant started growing.



Some of the leaves from the plant that died fell on the ground. I took some of them on the ground and stuck them in little pots. Well, well, they to started producing new plants. Who knows I may be in business!

Thursday, April 26, 2018

How do you query a SQLite database using Python?

Python uses the sqlite3 module written by Gerhard Häring. It provides a SQL interface compliant with the DB-API 2.0 specification described by PEP 249.

I launch the Python Shell in my All Programs.


PythonSQLite_00

Python 3.7.0b2 (v3.7.0b2:b0ef5c979b, Feb 28 2018, 01:32:48) [MSC v.1912 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.

Connecting to an existing SQLite database. UsersOwnerApr25.sqlite has a table called 'friends' with just one row of data.

 First you need to import sqlite3 and then establish a connection by providing the path to the database (note the direction of slashes).
---------------------
>>> import sqlite3
>>> conn=sqlite3.connect("C:/Users/Owner/Desktop/Blog2017/MSSS2017/SQLite3_DBS/UsersOwnerApr25.sqlite")
--------------------
After connecting create a cursor and the subsequently use the Execute() method of the cursor.

>>> c=conn.cursor()
>>> conn.commit()
-----------------------------------------------
For example, for inserting data into 'friends' table use the following statement. I already had a table with the name 'friends'
----------------------------------
>>> c.execute("Insert Into friends values('Jay', 'Kris',45)")

--This is something I need to figure out---

I try to print the results but I get the same response after the print() statement.
--------------------------------------
>>> y= c.execute('Select * from friends')
>>> print (y)

-----------------------------------------


Now I modify the print() statement and I succeed in printing the first row using the fetchone()method.
---------------------------------------
>>> print(c.fetchone())
('John', 'Chiavetta', 35)
-----------------------------
I print all the rows using the fetchall().
-----------------------------
>>> for row in c.execute('Select * from friends'):
print(row)

('John', 'Chiavetta', 35)
('Jay', 'Kris', 45)
>>>
-------
I have not figured out why I get this:



The IDLE interface is very useful as mentioned here. You get a lot of help.




Wednesday, April 25, 2018

How do you create database 'objects' in SQLite using command line?

In this post,

You will create a SQLite database and persist in your file system.
You will find the directory where the SQLite database is saved.
You will relaunch SQLite3 and access the persisted SQLite database file.
You will create a table.
You will test for tables in your computer/folder.
You will populate the table with some values.
You will run a SELECT query to find the table contents.

I created a desktop shortcut from the file location of sqlite3.exe in one of my folders and launched it. It opens with a command prompt, sqlite>.

The version is at the beginning of the prompt as shown.
SQLite version 3.23.1 2018-04-10 17:39:29
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.

Creating a database is easy. As shown here it creates a database (file) called 'aloha'.
---------
sqlite> .open aloha
sqlite>

-----------
It creates the database file ("aloha") in the directory which can be seen by the next command. The command .databases without any space after the C: prompt.
------------
sqlite> .databases
main: C:\Users\Owner\Desktop\Blog2017\MSSS2017\SQLite3_DBS\aloha
sqlite>

-------------------
Creating a table is easy as well. The following creates a table 'flower' in the database.
-----------------
sqlite> CREATE TABLE flower ( Id integer PRIMARY KEY, Ename varchar(20), Fname varchar(20));
-------------
Just check if you have any tables using .tables command as shown.
------------------------------------
sqlite> .tables
flower

---------------
Now exit sqlite3.
Launch sqlite3 again.

We will access the saved (persisted) database 'aloha'. Note that double quotes ("") spawns an error as shown. Filename within single quote ('') opens the database
----------------
sqlite> .open "C:\Users\Owner\Desktop\Blog2017\MSSS2017\SQLite3_DBS\aloha"
Error: unable to open database "C:UsersOwnerDesktopBlog2017MSSS2017SQLite3_DBSloha": unable to open database file

sqlite> .open 'C:\Users\Owner\Desktop\Blog2017\MSSS2017\SQLite3_DBS\aloha'
sqlite>

--------------------------------------
Populating the table is also SQL based.
-------------------
sqlite> INSERT INTO flower Values ('1','Hyacinth', 'Jasinth')
   ...> ;

--------------
Now you can run a SELECT query as shown.
--------------
sqlite> SELECT * FROM flower;
1|Hyacinth|Jasinth
sqlite>

-------------------------------

It is continued in the next post tomorrow.

Tuesday, April 24, 2018

How do I know which version of SQLite engine I am using?

I have quite a few SQLite versions on my computer and how do I know which one I am using? Well, here is a list of all SQLite I have on my recent laptop. They are all SQLite3.


When you launch SQLite you get to know the version.

OK, but how do I find it?

Another way is to use the command select sqlite_version();


On the other hand, in SQL Server you would query, Select @@Version

Monday, April 23, 2018

Where can I get the latest 64Bit / 32 Bit SQLite executable?

In my quest for resolving the problem with the SQLite for UWP from the MSDN site, I went through many of the sources for SQLite.

SQLite 64-bit is an in-process library that provides you with a zero config, transactional database engine.
T
he latest version, SQLite 3.23.0(x64) is available for download from here:

https://www.filehorse.com/download-sqlite-64/. This download (sqlite-dll-win64-x64-3230100) has only two files, sqlite3.def and sqlite3.dll. It does not have the executable sqlite3.exe.

This site has most files that you may want to use: Here is a screen capture of part of the site.


64BitDownload.png

For the x64bit laptop, this file (x32) was used:
fileinfo.png

The folder has the following files:

fileInfo2.png

The sqlite.exe opens the command-line as shown.


Help is available using the command .help as shown.
-----------------------
SQLite version 3.23.1 2018-04-10 17:39:29
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .help
.archive ...           Manage SQL archives: ".archive --help" for details
.auth ON|OFF           Show authorizer callbacks
.backup ?DB? FILE      Backup DB (default "main") to FILE
.bail on|off           Stop after hitting an error.  Default OFF
.binary on|off         Turn binary output on or off.  Default OFF
.cd DIRECTORY          Change the working directory to DIRECTORY
.changes on|off        Show number of rows changed by SQL
.check GLOB            Fail if output since .testcase does not match
.clone NEWDB           Clone data into NEWDB from the existing database
.databases             List names and files of attached databases
.dbinfo ?DB?           Show status information about the database
.dump ?TABLE? ...      Dump the database in an SQL text format
                         If TABLE specified, only dump tables matching
                         LIKE pattern TABLE.
.echo on|off           Turn command echo on or off
.eqp on|off|full       Enable or disable automatic EXPLAIN QUERY PLAN
.excel                 Display the output of next command in a spreadsheet
.exit                  Exit this program
.expert                EXPERIMENTAL. Suggest indexes for specified queries
.fullschema ?--indent? Show schema and the content of sqlite_stat tables
.headers on|off        Turn display of headers on or off
.help                  Show this message
.import FILE TABLE     Import data from FILE into TABLE
.imposter INDEX TABLE  Create imposter table TABLE on index INDEX
.indexes ?TABLE?       Show names of all indexes
                         If TABLE specified, only show indexes for tables
                         matching LIKE pattern TABLE.
.limit ?LIMIT? ?VAL?   Display or change the value of an SQLITE_LIMIT
.lint OPTIONS          Report potential schema issues. Options:
                         fkey-indexes     Find missing foreign key indexes
.load FILE ?ENTRY?     Load an extension library
.log FILE|off          Turn logging on or off.  FILE can be stderr/stdout
.mode MODE ?TABLE?     Set output mode where MODE is one of:
                         ascii    Columns/rows delimited by 0x1F and 0x1E
                         csv      Comma-separated values
                         column   Left-aligned columns.  (See .width)
                         html     HTML













































UWP: How do you connect to SQLite from a Universal Windows App?

SQLite is the right relational daatabase with zero configuration for mobile apps. There is a recipe in Microsoft documentation on using a SQLite database in a UWP app. This should be quite straight forward given a recipe but there are problems. Probably because of a plethora of versions of just about everything.

This post is not about a successful follow up of the recipe to its successful end, but steps in the way of achieving, trying to document as much as possible, firstly to find where things did not happen as expected, secondly to make sure it works, at least for me.

The computer is Windows 10 Version 1803, build 17133.73
SQLite for Universal Windows Platform added via Extensions and Update

The Solution for the app, UWPDataTest:

Universal Windows project-UWPDataTest
DataAccessLibrary -DataAccesLibrary


UWPDataTestPost_0

Microsoft.NETCore.UniversalWindowsPlatform used in the DataAccessLibrary(version 6.0.8)


UWPDataTestPost_2

Installed Microsoft.NETCore.UniversalWindowsPlatform


UWPDataTestPost_2a

DataAccessLibrary referenced in UWPDataTest


UWPDataTestPost_3

Using DataAccessLibrary in MainPage.xaml.cs


UWPDataTestPost_4

Using DataAccessLibrary in app.xaml.cs


UWPDataTestPost_5

DataAccess class made static.


UWPDataTestPost_6

Cannot add using Microsoft.Data.SQLite to class library. Data is not an option. If you add it and try to build you get build errors.


UWPDataTestPost_7
Build errors: DataAccessLibrary.dll could not be found. The DataAccessLibrary build has errors.


UWPDataTestPost_8.png

Error persists after upgrading the SQLite version from within VS Studio 2017.


UWPDataTestPost_9.png

Microsoft Visual Studio 2017 Community edition used.


UWPDataTestPost_10.png

I am not sure where the sqliteSample.db is in the computer. It does not seem to be present anywhere, although search is not guaranteed to work always.


UWPDataTestPost_11.png

The problem at present seems to be related to the absence of SQLite on the computer. Perhaps there is an independent source for the database.
Another possible source of error could be the Insiders Preview build may not support the SQLite added.