投稿時間:2023-03-12 18:10:13 RSSフィード2023-03-12 18:00 分まとめ(13件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
AWS lambdaタグが付けられた新着投稿 - Qiita ChatGPT の LINE bot(APIGatewa + Lambda) ハンズオン https://qiita.com/i3no29/items/d98e57f063e5f76410a9 chatgpt 2023-03-12 17:10:52
js JavaScriptタグが付けられた新着投稿 - Qiita Reactの環境設定を行う https://qiita.com/Jackoguro/items/5d62befceadd4ce5f9ca react 2023-03-12 17:34:58
js JavaScriptタグが付けられた新着投稿 - Qiita JavaScript/TypeScriptで変数初期化とreturnを一文で書く方法 https://qiita.com/takiuchi/items/5caacd171d5a6b9f8313 functiondotaskparamsco 2023-03-12 17:33:16
js JavaScriptタグが付けられた新着投稿 - Qiita 中学生が作った自分だけのMarkdownエディターに部分印刷機能をつけたお話 https://qiita.com/I-AM-RAILWAY-FAN/items/7b8752dbfe9d08be2800 https 2023-03-12 17:22:35
AWS AWSタグが付けられた新着投稿 - Qiita サーバレスで作るデータ分析基盤 https://qiita.com/rbrf7321/items/6500d2d1a641b553789b 高性能 2023-03-12 17:58:08
AWS AWSタグが付けられた新着投稿 - Qiita AWS Transit Gateway inter-Region Peeringによるリージョン間NW接続 https://qiita.com/Higemal/items/079b44971700ced8efea awstransitgateway 2023-03-12 17:17:55
AWS AWSタグが付けられた新着投稿 - Qiita ChatGPT の LINE bot(APIGatewa + Lambda) ハンズオン https://qiita.com/i3no29/items/d98e57f063e5f76410a9 chatgpt 2023-03-12 17:10:52
Azure Azureタグが付けられた新着投稿 - Qiita Microsoft 365 Certified: Fundamentals(MS-900)資格勉強方法 https://qiita.com/ice99skyblue/items/71afe584cc7cde0f6a65 azure 2023-03-12 17:18:47
海外TECH DEV Community Essential SQL Commands for Data Science https://dev.to/perekamoyo21/essential-sql-commands-for-data-science-284g Essential SQL Commands for Data ScienceSQL Structured Query Language is a programming language used to manage and manipulate relational databases It is used to create modify and query databases as well as perform data manipulation operations such as inserting updating deleting and retrieving data In this playlist you will get to know about different sql commands queries and all the sql functions for the data science youtube com SQL is a standard language meaning it can be used with different relational database management systems RDBMS such as MySQL Oracle Microsoft SQL Server and others The syntax and commands used in SQL may vary slightly depending on the specific RDBMS being used but the basic structure and principles of the language remain the same SQL is a declarative language meaning it focuses on specifying what data should be retrieved or manipulated rather than how it should be done Some common tasks performed using SQL include creating tables to store data inserting data into those tables querying data to retrieve specific information and updating or deleting existing data SQL can also be used to perform more advanced operations such as joining multiple tables aggregating data and creating views and stored procedures SQL Structured Query Language is a powerful tool for data science that allows you to manage and manipulate relational databases Here are some essential SQL commands for data science Simple Data RetrievalSELECT The SELECT keyword is used to retrieve data from one or more database tables When used in a SQL query it specifies the columns that should be included in the query result For example let s say we have a table called customers with columns customer id first name and last name To retrieve all data from this table we would use the following query SELECT FROM customers This would retrieve all columns from the customers table Alternatively if we only wanted to retrieve the customer id and first name columns we would use the following query SELECT customer id first nameFROM customers FROM The FROM keyword is used to specify the table or tables from which to retrieve data It is used in combination with the SELECT keyword to specify the source of the data being retrieved For example if we wanted to retrieve data from the orders table we would use the following query SELECT FROM orders DISTINCT The DISTINCT keyword is used to remove duplicate rows from the query result When used in a SQL query it specifies that only unique values should be included in the query result For example let s say we have a table called orders with columns order id customer id and order date If we wanted to retrieve only the unique customer IDs from this table we would use the following query SELECT DISTINCT customer idFROM orders This would retrieve only the unique customer IDs from the orders table and would exclude any duplicates In summary the combination of SELECT FROM and DISTINCT in a SQL query allows you to retrieve specific data from one or more tables while removing any duplicates in the query result Data Retrieval with Simple ConditionsWHERE The WHERE keyword is used to filter data based on a specified condition It is used in combination with the SELECT keyword to specify the criteria for selecting data from a table For example if we wanted to retrieve only the orders placed by a specific customer with a customer ID of we would use the following query SELECT FROM ordersWHERE customer id This would retrieve only the rows from the orders table where the customer ID is equal to ORDER BY The ORDER BY keyword is used to sort the query result by one or more columns in ascending or descending order It is used in combination with the SELECT keyword to specify the sorting order for the data being retrieved For example if we wanted to retrieve all orders from the orders table and sort them by order date in descending order we would use the following query SELECT FROM ordersORDER BY order date DESC This would retrieve all rows from the orders table and sort them in descending order based on the order date column LIMIT The LIMIT keyword is used to limit the number of rows returned by a query It is used in combination with the SELECT keyword to specify the maximum number of rows to retrieve For example if we only wanted to retrieve the first orders from the orders table we would use the following query SELECT FROM ordersLIMIT This would retrieve the first rows from the orders table based on the default sorting order of the table In summary the combination of WHERE ORDER BY and LIMIT in a SQL query allows you to filter sort and limit data retrieval based on specific conditions and criteria AggregationsGROUP BY The GROUP BY keyword is used to group data by one or more columns in a table It is used in combination with the SELECT keyword to specify how the data should be grouped For example if we wanted to count the number of orders for each customer in the orders table we would use the following query SELECT customer id COUNT FROM ordersGROUP BY customer id This would group the data by customer ID and count the number of orders for each customer COUNT The COUNT function is used to count the number of rows in a table or the number of non null values in a specific column It is used in combination with the SELECT keyword to specify what should be counted For example if we wanted to count the total number of orders in the orders table we would use the following query SELECT COUNT FROM orders This would count the total number of rows in the orders table SUM The SUM function is used to calculate the sum of values in a specific column It is used in combination with the SELECT keyword to specify which column should be summed For example if we wanted to calculate the total revenue from all orders in the orders table we would use the following query SELECT SUM order total FROM orders This would calculate the sum of the order total column in the orders table AVG The AVG function is used to calculate the average of values in a specific column It is used in combination with the SELECT keyword to specify which column should be averaged For example if we wanted to calculate the average order total for each customer in the orders table we would use the following query SELECT customer id AVG order total FROM ordersGROUP BY customer id This would group the data by customer ID and calculate the average order total for each customer HAVING The HAVING keyword is used to filter data based on a condition applied to an aggregated column It is used in combination with the GROUP BY keyword to specify the criteria for selecting data For example if we wanted to retrieve only the customers with a total order value greater than from the orders table we would use the following query SELECT customer id SUM order total FROM ordersGROUP BY customer idHAVING SUM order total gt This would group the data by customer ID and sum the order totals for each customer and then only retrieve the rows where the sum is greater than MIN The MIN function is used to calculate the minimum value in a specific column It is used in combination with the SELECT keyword to specify which column should be used For example if we wanted to retrieve the minimum order total from the orders table we would use the following query SELECT MIN order total FROM orders This would retrieve the minimum value in the order total column of the orders table Alias An alias is a shorthand name given to a table or column in a SQL query It is used to make the query more readable and can be used to rename columns or tables For example if we wanted to rename the order total column in the orders table to total we would use the following query SELECT customer id SUM order total JoinsJoins are used in SQL to combine data from multiple tables based on a common column The most common type of join is the INNER JOIN also known as the JOIN operation The INNER JOIN operation returns only the rows that have matching values in both tables being joined To perform an INNER JOIN we need to specify the tables to be joined and the columns on which to join them For example suppose we have two tables customers and orders with the following data customers table customer idcustomer namecustomer emailJohn Smithjohn gmail comJane Doejane gmail comBob Johnsonbob gmail comorders table order idorder totalcustomer idWe can join these tables using the following query SELECT FROM customersINNER JOIN ordersON customers customer id orders customer id This query would return the following result customer idcustomer namecustomer emailorder idorder totalcustomer idJohn Smithjohn gmail comJohn Smithjohn gmail comJane Doejane gmail comBob Johnsonbob gmail comIn this example we joined the customers and orders tables on the customer id column The resulting table contains all columns from both tables where the customer id values match The ON keyword is used to specify the join condition In this case we specified that the customer id column in the customers table should match the customer id column in the orders table Note that when joining tables it is important to use unique column names in each table or to use table aliases to disambiguate column names This ensures that the correct columns are used in the join condition and in the SELECT clause Changing Data TypesIn SQL we can use the CAST function to convert a value from one data type to another The syntax of the CAST function is as follows CAST expression AS data type Here the expression is the value that we want to convert and the data type is the data type to which we want to convert the expression For example suppose we have a table sales with a column sale amount that contains decimal values We want to convert these values to integers We can use the CAST function as follows SELECT CAST sale amount AS INTEGER FROM sales This query will return the sale amount values converted to integers Another useful function for working with numeric data is the ROUND function The ROUND function is used to round a numeric value to a specified number of decimal places The syntax of the ROUND function is as follows ROUND expression decimal places Here the expression is the value that we want to round and the decimal places is the number of decimal places to which we want to round the expression For example suppose we have a table products with a column price that contains decimal values We want to round these values to two decimal places We can use the ROUND function as follows SELECT ROUND price FROM products This query will return the price values rounded to two decimal places Complex ConditionsIn SQL we can use complex conditions to create more advanced filtering and logical expressions Complex conditions are created using logical operators such as AND OR and NOT and can be combined with parentheses to group expressions together For example suppose we have a table employees with columns first name last name and salary We want to select all employees who have a salary greater than and whose first name is not John We can use the following query SELECT FROM employeesWHERE salary gt AND NOT first name John This query will return all rows from the employees table where the salary column is greater than and the first name column is not John CASE Statement The CASE statement is used in SQL to perform conditional logic in the SELECT statement It allows us to define different output values based on the evaluation of one or more conditions The syntax of the CASE statement is as follows CASE WHEN condition THEN result WHEN condition THEN result ELSE default resultENDFor example suppose we have a table orders with columns order id and order total We want to create a new column called order type that categorizes orders as low medium or high based on their total amount We can use the following query SELECT order id order total CASE WHEN order total lt THEN low WHEN order total lt THEN medium ELSE high END AS order typeFROM orders This query will return all rows from the orders table with a new column order type that categorizes each order as low medium or high based on its order total value Subqueries A subquery is a SQL query that is nested inside another query Subqueries are useful when we need to perform a separate query to retrieve data that we will use in the main query For example suppose we have two tables customers and orders We want to find all customers who have placed an order in the last days We can use the following query SELECT FROM customersWHERE customer id IN SELECT customer id FROM orders WHERE order date gt DATEADD day GETDATE This query will return all rows from the customers table where the customer id is in the result set of a subquery that retrieves all customer id values from the orders table where the order date is within the last days Common Table Expressions CTEs A Common Table Expression CTE is a temporary named result set that we can reference within a SQL statement CTEs are useful for breaking down complex queries into smaller more manageable parts The syntax of a CTE is as follows WITH cte name AS SELECT SELECT FROM cte name For example suppose we have a table orders with columns order id and order total We want to calculate the total sales for each customer and then find the customers with the highest total sales We can use the following query with a CTE WITH customer sales AS SELECT customer id SUM order total AS total sales FROM orders GROUP BY customer id SELECT FROM customer salesWHERE total sales SELECT MAX total sales FROM customer sales In summary understanding essential SQL commands is crucial for data scientists to effectively manipulate and analyze data stored in relational databases These commands enable data scientists to retrieve filter group join aggregate and sort data and to perform various analytical tasks on it 2023-03-12 08:35:23
海外TECH DEV Community Spring, SchemaSpy DB docs, and GitHub Pages https://dev.to/kirekov/spring-schemaspy-db-docs-and-github-pages-pk6 Spring SchemaSpy DB docs and GitHub PagesIn this article I m telling you How to generate docs of database schema structure with SchemaSpy Why you need it if you use a relational database PostgreSQL Oracle MySQL etc in your application How to run SchemaSpy with Testcontainers How to host the generated database documentation on GitHub Pages The stack I m using in this project consists of Spring BootSpring Data JPAPostgreSQLYou can find the entire repository with code examples by this link The test that generates the SchemaSpy docs is available by this link What is SchemaSpy SchemaSpy is a standalone application that connects to the database scans its tables and schemas and generated nicely composed HTML documentation You can check out an example sample by this link but I m showing you just one screenshot to clarify my point SchemaSpy visualizes the database structure detailedly Besides you can also deep dive into relations constraints and table column comments i e COMMENT ON COLUMN TABLE statements Such documentation is helpful for a variety of specialists System analysts want to understand the data processing and storage principles behind the business logic When QA engineers face a bug the database structure documentation helps to investigate the reason that cause the problem deeply As a matter of fact they can also attach additional details to the ticket to make its fixing more transparent Data engineers have to be aware of tables structure to deal with Change Data Capture events correctly So database documentation that is always relevant because it s generated is excessively beneficent Database tablesLook at the DDL operations that create database tables This is our application domain we re going to document CREATE TABLE users id BIGSERIAL PRIMARY KEY name VARCHAR NOT NULL CREATE TABLE community id BIGSERIAL PRIMARY KEY name VARCHAR NOT NULL CREATE TABLE post id BIGSERIAL PRIMARY KEY name VARCHAR NOT NULL community id BIGINT REFERENCES community id NOT NULL CREATE TABLE community role id BIGSERIAL PRIMARY KEY user id BIGINT REFERENCES users id NOT NULL community id BIGINT REFERENCES community id NOT NULL type VARCHAR NOT NULL UNIQUE user id community id type CREATE TABLE post role id BIGSERIAL PRIMARY KEY user id BIGINT REFERENCES users id NOT NULL post id BIGINT REFERENCES post id NOT NULL type VARCHAR NOT NULL UNIQUE user id post id type As you can see there are core tables users community and role and linking tables community role post role Running SchemaSpy with TestcontainersThe easiest way to keep documentation in sync with the current database structure is updating it on each merged Pull Request Therefore we need somehow to run SchemaSpy during tests execution I m showing you the algorithm step by step But you can check out the entire suite by this link Firstly we need to define the SchemaSpy container itself Look at the code snippet below class SchemaSpyTest extends AbstractControllerTest Test SneakyThrows void schemaSpy Cleanup final var schemaSpy new GenericContainer lt gt DockerImageName parse schemaspy schemaspy withNetworkAliases schemaspy withNetwork NETWORK withLogConsumer new SlfjLogConsumer LoggerFactory getLogger SchemaSpy withCreateContainerCmdModifier cmd gt cmd withEntrypoint withCommand sleep The AbstractControllerTest contains PostgreSQL container configuration You can see its source code by this link The Cleanup annotation comes from the Lombok project It generates try finally statement I want to point out some important details here The withNetwork clause assigns the container to the existing Testcontainers NETWORK This value inherits from the AbstractControllerTest and the PostgreSQL runs with this network as well It s crucial because otherwise SchemaSpy won t be able to connect to PostgreSQL Log consumer applies a logger to push logs from the container It s useful to track bugs and errors The withCreateContainerCmdModifier is the primary part By default SchemaSpy container tries to connect to a database immediately and generate documentation Then a container terminates However that s not an acceptable behaviour because the generation result remains inside container Therefore we need to copy it in the OS directory But if a container has already stopped it s impossible So we have to override a default entry point to make a container run almost indefinitely That s why I put the sleep command Container will hang and do nothing on its start Now we need to trigger the generation process Look at the code block below schemaSpy start schemaSpy execInContainer java jar schemaspy jar t pgsql db POSTGRES getDatabaseName host postgres u POSTGRES getUsername p POSTGRES getPassword o output dp drivers inc debug schemaSpy execInContainer tar czvf output output tar gz output Here is what happens I start the container remember that it hangs and does nothing Then I execute the command that generates the documentation The host equals to postgres because that s the PostgreSQL container s network alias the withNetworkAliases method The command execution happens in a separate process inside the container So the sleep command is not terminated Finally we put the directory with generated contents HTML CSS JS into a tarball Testcontainers library allows to copy files from a container to the OS but not directories That s why we need an archive inside the SchemaSpy container It s time to copy the result documentation in the OS directory and unpack the changes Look at the code snippet below final var buildFolderPath Path of getClass getResource toURI toAbsolutePath schemaSpy copyFileFromContainer output output tar gz buildFolderPath resolve output tar gz toString schemaSpy stop final var archiver ArchiverFactory createArchiver tar gz archiver extract buildFolderPath resolve output tar gz toFile buildFolderPath toFile The steps are Define the buildFolderPath that points to the build classes java test directory I use Gradle in this project Then I copy the tarball with documentation from the container to the buildFolderPath directory And finally I unpack the archive contents to the same directory I use jararchivelib library here In the end we have a pretty documentation generated on the database schema structure Look at the screenshot below Hosting result on GitHub PagesWe got generated documentation based in build classes java test folder Anyway it s not that useful yet We need to host it on GitHub Pages and update accordingly Look at the pipeline definition below name Java CI with Gradleon push branches master permissions contents read pages write id token writejobs build and deploy environment name github pages url steps deployment outputs page url runs on ubuntu latest steps uses actions checkout v name Set up JDK uses actions setup java v with java version distribution temurin name Build with Gradle run gradlew build name Upload artifact uses actions upload pages artifact v with path build classes java test name Deploy to GitHub Pages id deployment uses actions deploy pages vThe actions are Build the project and run tests with Set up JDK and Build with Gradle steps Then the Upload artifact step uploads the build classes java test directory folder to GitHub registry it contains the documentation And finally deploy the artefact created on the previous step to the GitHub Pages That s basically it Now the SchemaSpy documentation is available on GitHub Pages and being updated automatically on each merged Pull Request ConclusionThat s all I wanted to tell you about generating database schema documentation and hosting the result on GitHub Pages Do you have any docs generation automations in your project Is it SchemaSpy or something else Do you host the result on GitHub or GitLab Pages Tell your story in the comments It ll be interesting to discuss your experience as well Thanks for reading If you like that piece press the like button and share the link with your friends ResourcesThe repository with code examplesCode of the test that runs SchemaSpy containerGitHub Pages final documentationSchemaSpyTestcontainersGitHub PagesSpring Data JPAPostgreSQLSchemaSpy documentation samplePostgreSQL COMMENT ON COLUMN TABLE statementsChange Data Capture eventsCleanup annotationTry finally statementGitHub issue copyFileFromContainer is there a way to copy a folder GradleJararchivelib 2023-03-12 08:21:30
海外TECH DEV Community RxJS 7 - Observables https://dev.to/barisbll/rxjs-7-observables-2kc RxJS ObservablesHere are my detailed notes from the fantastic course created by Jurek Wozniak called RxJS and Observables Introduction In order to understand the concept please consider buying the course yourself these notes are simply subsidiaries Observables How Do They Work Array vs StreamObservables are based around the idea of streams that means the data can come in different parts of time and number of data can be theoretically infiniteThe biggest different between arrays is in arrays all the values inside are already known With the stream approach we react to the things when they show upFor example we first see a lemon and we react to it or not then coconut etc We can for example have a stream for mouse positions text input data change http requests Observable Subscription Observer Key ElementsObservable is quite simple once an observable is executed it emits some notifications There are types of notificationsNextErrorCompleteFor now we fill focus to the next notification which allows us to emit notifications Warm Up Observable Observable Observer SubscriptionObservable doesn t do anything by itself it just has some logic stored inside We need to subscribe to it to make it workSubscription should be closed when we are done with them in order to avoid memory leakage and unexpected behaviorus Subscriptions can be stopped in ways It can stop automatically by the observable logic itself with error or complete notificationsWe can cancel it by unsubscribingimport Observable from rxjs const observable new Observable lt string gt subscriber gt console log Observable executed subscriber next Alice setTimeout gt subscriber next Ben setTimeout gt subscriber next Charlie const subscription observable subscribe value gt console log value setTimeout gt console log Unsubscribe subscription unsubscribe One of the most important thing here is how we unsubscribe to observable by calling the subscription object We received subscription object as return value of subscribe function and we could also use observer like thisconst observer next value gt console log value However since we just need to have a next function we used simple function version Usually this small just function version is used in projects Multiple SubscriptionsWhat happens if observers subscribe to the same observable Well just as you would expect they work independently and execute through all observable streamimport Observable from rxjs const observable new Observable lt string gt subscriber gt console log Observable executed subscriber next Alice setTimeout gt subscriber next Ben setTimeout gt subscriber next Charlie console log Subscription starts observable subscribe value gt console log Subscription value setTimeout gt console log Subscription starts observable subscribe value gt console log Subscription value OutputSubscription startsObservable executedSubscription AliceSubscription startsObservable executedSubscription AliceSubscription BenSubscription BenSubscription CharlieSubscription CharlieComplete notification is sent only if all the messages are sent and it is telling us that it has nothing more to share What Next This is the second article of a series of articles I write about RxJS Do not stop here Continue reading See the first article Let s keep in touchHey thanks a lot if you read it so far I want you to keep in touch for more sweet content Please subscibe in Dev to and other channels ‍ ️especially twitter Twitter Linkedin Github ‍Medium barisbll 2023-03-12 08:11:09
ニュース BBC News - Home Israel sees one of its biggest-ever protests https://www.bbc.co.uk/news/world-middle-east-64929563?at_medium=RSS&at_campaign=KARANGA israel 2023-03-12 08:47:58
ニュース BBC News - Home Hemsby cliff-top home demolished before it falls on beach https://www.bbc.co.uk/news/uk-england-norfolk-64930934?at_medium=RSS&at_campaign=KARANGA cliff 2023-03-12 08:23:23

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)