[LINUX] Easy Raspberry Pi GUI App Development Beginner Part 1

Easy Raspberry Pi GUI App Development Beginner Part 1

  1. Use of Sqlite3 --Introduction of Dapper I tried to summarize Dapper --Introduction of Dapper Extension Comparison of Dapper extension libraries --Use Swagger Use Stoplight Studio etc. OpenAPI (Swagger) tool that I'm really glad to use --Run Python from C # Call Python script from C # --Realization of binding between DataGridView and Model URL treeView --How to deploy to Raspberry Pi

Development is done on Visual Sudio Mac on Mac

Up to 5 in the first part

Sample File

Select Gtk # for the project

About GTK #

スクリーンショット 2020-04-09 19.34.07.png
Download packages from Nuget
スクリーンショット 2020-04-09 19.36.00.png
Package to download

Dapper DapperExtensions Download Mono.Data.Sqlite. In case of Gtk2 #, System.Data.Sqlite cannot be read.

スクリーンショット 2020-04-09 19.10.43.png

Query using Dapper

Dapper Tutorial

Query results can be automatically included in the model. Also, Model can be used instead of the argument at the time of Update at Insert.

        static public void _dapperTest() {

            Mono.Data.Sqlite.SqliteConnection connection = new Mono.Data.Sqlite.SqliteConnection();
 
            connection.ConnectionString = @"Data Source=path/test.sqlite";
            connection.Open();

            var query = "select * from testTable;";

            var result = connection.Query<testTable>(query);
            foreach(var p in result) {
                Console.WriteLine("ID:" + p.test_id + "name:" + p.name);
            }

            connection.Close();
        }

Insert Update processing using Dapper Extension

Insert statement and Update statement can be automatically generated and processed from Model

About Dapper Extension

Change the format of the exported Sql statement

DapperExtensions.DapperExtensions.SqlDialect = new DapperExtensions.Sql.SqliteDialect();
        static public void _dapperExtensionTest() {

            //Sql statement[testTable].[test_id]From[test_id]Change to
            DapperExtensions.DapperExtensions.SqlDialect = new DapperExtensions.Sql.SqliteDialect();

            Mono.Data.Sqlite.SqliteConnection connection = new Mono.Data.Sqlite.SqliteConnection();

            connection.ConnectionString = @"Data Source=path/test.sqlite";
            connection.Open();

            //Processing using Dapper Extension
            testTable testTable1 = new testTable();
            testTable1.name = "aaaaaa111";
            connection.Insert<testTable>(testTable1);

            var query = "select * from testTable;";
            var result = connection.QueryFirst<testTable>(query);

            //Processing using Dapper Extension
            result.name += "qqqq111";
            connection.Update<testTable>(result);

            connection.Close();

        }

testTable model

  1. Be sure to write a Getter Setter on the model **
 public class testTable {

	public int test_id { get; set; }

	public string name { get; set; }
 }

Make Swagger automatically generated

Use Stoplight Studio. Register the API URL and parameters, and Swagger will be generated automatically.

OpenAPI (Swagger) tool that I really liked to use

スクリーンショット 2020-04-07 21.53.05.png

Automatically generate API client, stub server, HTML definition document with Swagger Codegen

Install Swagger Codegen and export the API client and model file in the specified language. It is convenient to customize the template.

Automatically generate various RESTful API definitions with OpenAPI Generator Swagger Codegen Swagger Codegen Git

swagger-codegen generate -i http://petstore.swagger.io/v2/swagger.json -l Specify the language(csharp) -o Output directory

I touched swagger for the first time

Free product list in Azure

Azure Functions Free

Points for development

  1. Gtk2 # uses Mono.Data.Sqlite. Could be used with Dapper
  2. I had a hard time finding a sample of gtk. ** C # gtk hotexamples When I searched with the method name I want to check **, I found a site that can list the samples posted on git.
  3. Be sure to write a getter setter in the model

DataMapping

スクリーンショット 2020-04-09 13.42.35.png

Easy Raspberry Pi GUI App Development Beginner Part 2 Easy introduction to Raspberry Pi Gui application development Easy Raspberry Pi GUI application development parts sample collection

Recommended Posts

Easy Raspberry Pi GUI App Development Beginner Part 1
Easy Raspberry Pi GUI App Development Beginner Part 2
raspberry pi 1 model b, node-red part 17
Easy GUI app with Tkinter Text
"Honwaka Notification Lamp" on Raspberry Pi Part 2
"Honwaka Notification Lamp" on Raspberry Pi Part 1
"Honwaka Notification Lamp" on Raspberry Pi Part 3
Matrix multiplication on Raspberry Pi GPU (Part 2)
[Python] Udemy Image Judgment AI App Development Part1
Easy connection between Raspberry Pi and AWS IoT
Stock investment analysis app made with Raspberry Pi
Build a Python development environment on Raspberry Pi
Raspberry Pi backup
Easy IoT to start with Raspberry Pi and MESH
Problems and countermeasures in smartphone app game development Part 1
Try to visualize the room with Raspberry Pi, part 1
Problems and countermeasures in smartphone app game development Part 2