end0tknr's kipple - web写経開発

太宰府天満宮の狛犬って、妙にカワイイ

「公用文作成の考え方」について(建議) by 文化庁

先日、entryに記載した「理科系の作文技術」と同様、文章の記載方法をまとめたもの。

記載内容は同様ですが、こちらは、令和4年(2022年)作成のためでしょうか、 読みやすい印象を受けます。

以下は p.8の抜粋

opencv for python で画像を比較し、pillow for python で結果をマルチページtiffにまとめる

import cv2
from PIL import Image

def highlight_differences(image1_path, image2_path, output_path):
    # 画像を読み込む
    image1 = cv2.imread(image1_path)
    image2 = cv2.imread(image2_path)

    # 画像をグレースケールに変換
    gray1 = cv2.cvtColor(image1, cv2.COLOR_BGR2GRAY)
    gray2 = cv2.cvtColor(image2, cv2.COLOR_BGR2GRAY)

    # 画像の差分を計算
    diff = cv2.absdiff(gray1, gray2)

    # 差分を二値化
    _, thresh = cv2.threshold(diff, 30, 255, cv2.THRESH_BINARY)

    # 輪郭を検出
    contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

    # 差分をハイライト
    for contour in contours:
        (x, y, w, h) = cv2.boundingRect(contour)
        cv2.rectangle(image1, (x, y), (x + w, y + h), (0, 0, 255), 2)

    # ハイライトされた画像を保存
    cv2.imwrite(output_path, image1)

    # ハイライトされた画像を表示
    # cv2.imshow('Differences', image1)
    cv2.waitKey(0)
    cv2.destroyAllWindows()

    # 2ページ目にimg_2を追加して保存
    add_image_to_tiff(output_path, image2_path)

def add_image_to_tiff(tiff_path, image_path):
    # 既存のTIFFファイルを読み込む
    tiff_image = Image.open(tiff_path)
    # 追加する画像を読み込む
    new_image = Image.open(image_path)

    # 既存のTIFFファイルのページをリストに追加
    images = [tiff_image]
    try:
        while True:
            tiff_image.seek(tiff_image.tell() + 1)
            images.append(tiff_image.copy())
    except EOFError:
        pass

    # 新しい画像をリストに追加
    images.append(new_image)

    # すべての画像を新しいTIFFファイルとして保存
    images[0].save(tiff_path, save_all=True, append_images=images[1:], compression="tiff_deflate")

img_1 = "IMAGE_01.tif"
img_2 = "IMAGE_02.tif"
diff_2 = "IMAGE_diff.tif"

# 使用例
highlight_differences(img_1, img_2, diff_2)

理科系の作文技術 - オレオレ要約

https://www.amazon.co.jp/dp/4121006240

(要約というより) 久しぶりに読み返したので、 押さえておきたいポイントを目次単位で記載しておきます。

序章

  • 必要なことは洩れなく記述し、必要ないことは書かない
  • 事実と意見を区別する
  • あいまいな表現を避け、普通の用語を用いる
  • 短い文で文章を構成する

2章 準備作業 (立案)

  • 自分の書こうとする文書の役割を確認する
  • 一つの文書は一つの主題に集中する

3章 文章の組立て

  • 重点先行主義 (世の中が忙しくなった為)
  • 概観から細部へ

4章 パラグラフ(段落)

  • パラグラフは一つのトピックについて記述・明言・主張する
  • パラグラフの趣旨を述べたトピックセンテンスを先頭に書く
  • 各パラグラフのトピックセンテンスで、文章全体の要約ができる

5章 文の構造と文章の流れ

  • 文も文章も、逆茂木型(さかもぎ)を避ける (重点先行主義)

6章 はっきり言い切る姿勢

  • ほぼ、約、ほど、ぐらい、たぶん、ような、らしいの類を削る

7章 事実と意見

  • 事実と意見を明確に区別する

8章 わかりやすく簡潔な表現

  • 文は短く (不要な言葉を削る。主語を意識する)
  • 能動態で書くと,読みやすく、文も短くなる(例: 思われる→思う)
  • 読点(、)のルール (受けることばが,離れているとき等 ※1)

※1 句点「。」と読点「、」の決まりを知る | 日経クロステック(xTECH)

9章 執筆メモ

省略

10章 手紙・説明書・原著論文

省略

11章 学会講演の要領

省略

DWG to SVG Converter by AnyDWG Software のコマンドライン版で、DWG →SVG 変換

AutoCAD自体には、SVGへのexport機能がありません。 触ってみた範囲では「DWG to SVG Converter」のコマンドライン版がよいです。

変換元のDWGの描き方によっては、正しくSVGへ変換できない場合もあると思いますが

コマンドライン版の実行例は以下

DOS> "C:\Program Files\WindowsApps\24512AnyDWGSoftware.DWGtoSVGConverter_2027.0.0.0_x64__b1tgcyechd9ap\VFS\ProgramFilesX86\DWG to SVG Converter\ds_10.exe"
    /InFile .\CAD_DWG\AUTOCAD-01-015-cad-.dwg
    /OutFile .\CAD_SVG\AUTOCAD-01-015-cad-.svg /Hide /Overwrite /OutLayout Paper /BGColor 0,0,0

import from utf-8 csv to SQL Server 2025 for Windows

目次

bcp import from utf-8 csv to SQL Server 2022 for Linux - end0tknr's kipple - web写経開発

以前のentryに対しての SQL Server 2025 express edition for Windows

step1 - export from SAP ASE for Linux

SAP ASE ≒ SQL Server で、sqlbcpコマンドも、ほぼ同様に利用できます。

SAP Help Portal | SAP Online Help

bcpコマンドでtableの全recordをexportする場合

$ bcp xerial..kousei  out kousei.csv -Uxsuser -Pxerial -Sxerial -c -t,

bcpコマンドでtableの特定のrecordをexportする場合

$ bcp "SELECT * FROM xerial..kousei WHERE body_mark='A' and ms in('F','M')" \
    queryout kousei.csv -Uxsuser -Pxerial -Sxerial -c -t,

step2 - import by strawberry perl

SQL Server 2025 express にも bcpコマンドは付属しますが、 なぜか、エラーになった為、今回はperl scriptでimport しています。

#!c:/Strawberry/perl/bin/perl
use utf8;
use strict;
use warnings;
use DBI;
use Data::Dumper;
use Encode;
use IO::Uncompress::Unzip qw/$UnzipError/;
use Text::CSV;

my $BCP_DIR = "c:/Users/????/dev/BCP";
my $BULK_INSERT_SIZE = 20;

main();

sub main {
    my $dbh = connect_db();

    my $tbl_names = [
        "plan_attr",
        "arrange_kmatrix",
        "arrange_oya",
        "arrange_rlkousei",
        "arrange_skousei"
        ];
    for my $tbl_name ( @$tbl_names ){
        print "TABLE : $tbl_name\n";
        my $zip_path = "$BCP_DIR/$tbl_name.zip";
        my $org_rows = load_zip_csv( $tbl_name, $zip_path );

        import_csv($dbh, $tbl_name, $org_rows);
    }

    $dbh->disconnect;
}

sub import_csv {
    my ($dbh, $tbl_name, $org_rows) = @_;

    my $col_size = scalar(@{$org_rows->[0]});
    my $sql_head = "INSERT INTO $tbl_name VALUES";
    my $values   = "(". join(",",("?")x scalar($col_size)) .")";
    my $sql = $sql_head . $values;
    my $sth = $dbh->prepare($sql);

    my $i = 0;
    my @buffer;

    for my $csv_cols ( @$org_rows ){
        $i++;
        if( $i % 5000 == 0 ){
            print "import_csv() for $tbl_name $i / ",
                scalar(@$org_rows) , "\n";
        }

        if ( scalar(@$csv_cols) < $col_size ){
            next;
        }

        push @buffer, $csv_cols;

        if (@buffer >= $BULK_INSERT_SIZE) {
            bulk_insert($sth, \@buffer);
            $dbh->commit;
            @buffer = ();
        }
    }

    bulk_insert($sth, \@buffer) if @buffer;
    $dbh->commit;
    print "DONE import_csv() for $tbl_name\n";
    return $i;
}

sub bulk_insert {
    my ($sth, $rows) = @_;
    return unless @$rows;

    my $col_count = @{ $rows->[0] };
    my @bind;

    for my $col (0 .. $col_count - 1) {
        push @bind, [ map { $_->[$col] } @$rows ];
    }
    $sth->execute_array({}, @bind);
}

sub load_zip_csv {
    my ($tbl_name, $zip_path) = @_;
    my $unzip = IO::Uncompress::Unzip->new( $zip_path )
        or die "$zip_path $UnzipError $!";
    my $csv = Text::CSV->new({binary=>1, auto_diag=>1, decode_utf8 =>1});

    my $ret_datas = [];
    while (1) {
        my $csv_name = $unzip->getHeaderInfo->{Name};
        #next unless $csv_name =~ /\.csv$/io;

        my $i = 0;
        while(my $row = $csv->getline($unzip)) {
            $i++;
            if( $i % 5000 == 0 ){
                print "load_zip_csv() for $tbl_name $i\n";
            }

            if( scalar(@$row) < 1 ){
                last;
            }

            if( $tbl_name eq "plan_attr" ) {
                shift( @$row );
                pop( @$row );
            }

            my $cols = [];
            for my $col ( @$row ){
                push( @$cols, trim($col) );
            }
            push(@$ret_datas, $cols);
        }

        my $status = $unzip->nextStream();
        last unless $status;
    }
    return $ret_datas;
}

sub connect_db {
    my $dsn = 'dbi:ODBC:nserial';
    my $dbh = DBI->connect(
        $dsn,
        undef,   # Windows 認証なので不要
        undef, {RaiseError=>1, AutoCommit=>0}) or die $DBI::errstr;

    my $sth = $dbh->prepare("use nserial");
    unless( $sth->execute() ){
        print STDERR $sth->errstr, "\n";
        return undef;
    }
    return $dbh;
}

sub trim {
    my ($val) = @_;
    $val =~ s/^[\s ]*(.*?)[\s ]*$/$1/go;
    if( length($val)==0){
        $val = "";
    }
    return $val;
}
__END__
1;

Document AI yomitoku for python で png画像を html化

oss版と商用版があるようですが、oss版で十分すごいです

https://github.com/kotaro-kinoshita/yomitoku

# -*- coding: utf-8 -*-
import yomitoku
import glob
import logging
import os
import torch
from tensorflow.python.client import device_lib;

logger = None
device = None
src_png_dir = "ns_png"
src_html_dir = "ns_html"


def main():
    # GPU接続確認 https://end0tknr.hateblo.jp/entry/20240814/1723617124
    chk_gpu()

    # logger初期化 - yomitokuが既にloggerを設定している為
    loggers = init_loggers()
    global logger
    logger = loggers[0]

    # --- GPU設定 ---
    global device
    device = "cuda" # cpu or cuda

    # --- PDFのmarkdown化 ---
    conv_png_to_html(src_png_dir, device)

def chk_gpu():
    print( "torch.cuda.is_available() :", torch.cuda.is_available() )
    print( "torch.version.cuda :", torch.version.cuda )
    print( "torch.cuda.device_count() :", torch.cuda.device_count() )
    print( "torch.cuda.get_device_name() :", torch.cuda.get_device_name() )
    print( "device_lib.list_local_devices() :", device_lib.list_local_devices() )
    

def conv_png_to_html(src_png_dir, device):
    doc_analyzer = yomitoku.DocumentAnalyzer(device=device )
    ret_base_dir = src_html_dir

    for i, src_png_path in enumerate(glob.glob(src_png_dir + "/**/*.png",
                                               recursive=True)):
        print(i, src_png_path)
        (src_dir, src_filename) = os.path.split(src_png_path)

        md_dir = src_dir.replace(src_png_dir, src_html_dir)
        if not os.path.exists(md_dir):
            os.makedirs(md_dir)

        basename = os.path.splitext(src_filename)[0]
        html_path = src_html_dir + "/" + basename + ".html"

        imgs = yomitoku.data.functions.load_image(src_png_path)
        for j, img in enumerate(imgs):
            results, ocr_vis, layout_vis = doc_analyzer(img)
            results.to_html(html_path, img=img )
    return ret_base_dir

def init_loggers():
    """ yomitokuが内部に持つloggerを設定変更 """
    ret_datas = []
    for logger_name in ['yomitoku', 'yomitoku.base']:
        tmp_logger = logging.getLogger(logger_name)
        tmp_logger.setLevel(logging.INFO) # 出力levelをINFOへ

        for handler in tmp_logger.handlers:
            if isinstance(handler, logging.StreamHandler):
                tmp_logger.removeHandler(handler)

        fh = logging.FileHandler(logger_name + ".log", encoding='utf-8')
        formatter = logging.Formatter(
            '%(asctime)s %(name)s %(levelname)s %(message)s')
        fh.setFormatter(formatter)

        tmp_logger.addHandler(fh)
        ret_datas.append(tmp_logger)

    return ret_datas

if __name__ == '__main__':
    main()

sqlcmd for SQL Server で CREATE DATABASEやCREATE TABLE等の練習

目次

sqlcmd から SQL serverへ接続

DOS> sqlcmd -S tcp:localhost,1433 -E

version表示

1> SELECT @@VERSION;
2> GO
------------------------------------------------------------
Microsoft SQL Server 2025 (RTM) - 17.0.1000.7 (X64)
【省略】

CREATE DATABASE、DB一覧表示

1> CREATE DATABASE nstest;
2> GO

1> sp_helpdb
2> GO
name     db_size  owner  dbid  created     status                    
------------------------------------------------------------------------------
master   8.50 MB  sa        1  04  8 2003 【略】Collation=Japanese_CI_AS,【略】
tempdb  16.00 MB  sa        2  12 27 2025 【略】Collation=Japanese_CI_AS,【略】
model   16.00 MB  sa        3  04  8 2003 【略】Collation=Japanese_CI_AS,【略】
msdb    24.44 MB  sa        4  10 21 2025 【略】Collation=Japanese_CI_AS,【略】
nstest  16.00 MB  a64\end0t 5  12 28 2025 【略】Collation=Japanese_CI_AS,【略】

LOGIN USER & DB USER追加、ユーザ一覧表示

1> use master
2> go

1> sp_addlogin nsuser, nsuser
2> go

1> sp_addlogin nsuser_r, nsuser_r
2> go

1> use nstest
2> go
データベース コンテキストが 'nstest' に変更されました。

1> sp_adduser nsuser
2> go

1> sp_adduser nsuser_r
2> go

1> sp_helpuser
2> go

UserName            RoleName  LoginName  DefDBName  DefSchemaName  UserID SID
-------------------------------------------------------------------------------
dbo                 db_owner  a64\end0t  master     dbo            1     【略】
guest               public    NULL       NULL       guest          2      0x00
INFORMATION_SCHEMA  public    NULL       NULL       NULL           3      0xNULL
sys                 public    NULL       NULL       NULL           4      0xNULL
nsuser              public    nsuser     master     nsuser         5     【略】
nsuser_r            public    nsuser_r   master     nsuser_r       6     【略】

CREATE TABLE、GRANT

USE nstest
GO
--
IF EXISTS (select name from sysobjects where name="arrange_3mps")
 BEGIN
  DROP TABLE arrange_3mps
 END
GO

CREATE TABLE arrange_3mps (
  plan_num      char(9) DEFAULT ' '  NOT NULL,
  edition       char(3) DEFAULT ' '  NOT NULL,
  addition_num  char(2) DEFAULT ' '  NOT NULL,
  parent_flag   tinyint              NOT NULL,    
  lin_pos       tinyint              NOT NULL,    
  col_pos       tinyint              NOT NULL,    
  part_num      char(15) DEFAULT ' ' NOT NULL,
  use_division  char(1)  DEFAULT ' ' NOT NULL,
/* create primary key */
constraint arrange_3mps_uidx
 primary key clustered
  (plan_num,addition_num,edition,parent_flag,lin_pos,col_pos)
)
GO
GRANT SELECT, INSERT, DELETE, UPDATE ON arrange_3mps TO public
GRANT SELECT, INSERT, DELETE, UPDATE ON arrange_3mps TO nsuser
GRANT SELECT ON arrange_3mps TO nsuser_r
GO

ユーザTABLE一覧表示

SELECT name
FROM sysobjects
WHERE type = 'U'
ORDER BYname
GO

name
------------
arrange_3mps

TABLE定義表示

1> sp_help arrange_3mps
2> go

Name          Owner  Type        Created_datetime
--------------------------------------------------------
arrange_3mps  dbo    user table  2025-12-28 17:50:23.027

Column_name   Type    Computed  Length【略】 Collation
-----------------------------------------------------------
plan_num      char    no        9            Japanese_CI_AS
edition       char    no        3            Japanese_CI_AS
addition_num  char    no        2            Japanese_CI_AS
parent_flag   tinyint no        1 3
lin_pos       tinyint no        1 3
col_pos       tinyint no        1 3
part_num      char    no        15           Japanese_CI_AS
use_division  char    no        1            Japanese_CI_AS

Identity  Seed  Increment  Not For Replication
----------------------------------------------
No identity column defined.

RowGuidCol                                                                                                          
-----------------------------
No rowguidcol column defined.                                                                                       

Data_located_on_filegroup                                                                                           
-----------------------------
PRIMARY                                                                                                             

index_name         index_description                                  index_keys
-------------------------------------------------------------------------------------------------------------------------------
arrange_3mps_uidx  clustered, unique, primary key located on PRIMARY  plan_num,addition_num,edition,parent_flag,lin_pos,col_pos

constraint_type                constraint_name           【略】constraint_keys
------------------------------------------------------------------------------------------------------------------------
PRIMARY KEY (clustered)        arrange_3mps_uidx               plan_num,addition_num,edition,parent_flag,lin_pos,col_pos
DEFAULT on column addition_num DF__arrange_3__addit__5EBF139D  (' ')
DEFAULT on column edition      DF__arrange_3__editi__5DCAEF64  (' ')
DEFAULT on column part_num     DF__arrange_3__part___5FB337D6  (' ')
DEFAULT on column plan_num     DF__arrange_3__plan___5CD6CB2B  (' ')
DEFAULT on column use_division DF__arrange_3__use_d__60A75C0F  (' ')

u

SQL Server 2025 Express への perl & odbc接続

目次

step 1 - ODBCデータベース(64ビット)で設定

ポイントは、サーバー欄への「tcp:localhost,1433」

step 2 - strawberry perl + odbcでの接続

DBI、DBD::ODBCperlモジュールのインストール

DOS> cpan DBI
DOS> cpan DBD::ODBC

odbcで接続するまでの perl script

#!c:/Strawberry/perl/bin/perl
use utf8;
use strict;
use warnings;
use DBI;
use Data::Dumper;

main();

sub main {
    my $dbh = connect_db();
    print Dumper( $dbh );
    
    $dbh->disconnect;
}

sub connect_db {
    my $dsn = 'dbi:ODBC:SQLEXPRESS_TCP';
    
    my $dbh = DBI->connect(
        $dsn,
        undef,   # Windows 認証なので不要
        undef,
        {RaiseError => 1,AutoCommit => 1}) or die $DBI::errstr;

    return $dbh;
}

SQL Server 2025 Express のインストール ~ sqlcmd.exe での接続

目次

step 1 - SQL Server 2025 Express & ODBCドライバ & sqlcmd.exe のインストール

https://www.microsoft.com/ja-jp/sql-server/sql-server-downloads からインストーラの SQL2025-SSEI-Expr.exe をダウンロードし、実行。

インストール完了画面に表示される CONNECTION STRING は、 今後、利用するかもしれませんので、以下へコピーしておきます。

Server=localhost\SQLEXPRESS;Database=master;Trusted_Connection=True;

続けて SSMS (SQL Server Management Studio)もインストールできるようですが、 今回はインストールしません。

「Connect Now」をクリックすると、コマンドプロンプトが起動し、 「sqlcmd -S A64\SQLEXPRESS -No -E」で SQL Serverへの接続と、 select @@Version の SQLが実行されます。

--
-- run below commmand from command prompt
-- sqlcmd -S A64\SQLEXPRESS -No -E
--

select @@Version
go

-----------------------------------------------------------------------
Microsoft SQL Server 2025 (RTM) - 17.0.1000.7 (X64)
  Oct 21 2025 12:05:57
  Copyright (C) 2025 Microsoft Corporation
  Express Edition (64-bit) on Windows 10 Pro 10.0 <X64> (Build 26200: )

(1 行処理されました)
1>

ODBCドライバも併せてインストールされます

また、コマンドラインツールである sqlcmd.exe もインストールされます

DOS> where sqlcmd
C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\180\Tools\Binn\SQLCMD.EXE

DOS> sqlcmd -?
sqlcmd: Install/Create/Query SQL Server, Azure SQL, and Tools

Version: v1.9.0

Flags:
-K,--application-intent
   Declares the application workload type when connecting to a
   server. The only currently supported value is ReadOnly.
   If -K is not specified, the sqlcmd utility will not
   support connectivity to a secondary replica in an Always
   On availability group

   --authentication-method
   Specifies the SQL authentication method to use to connect
   to Azure SQL Database. One of: ActiveDirectoryDefault,
   ActiveDirectoryIntegrated, ActiveDirectoryPassword,
   ActiveDirectoryInteractive,
   ActiveDirectoryManagedIdentity,
   ActiveDirectoryServicePrincipal,
   ActiveDirectoryServicePrincipalAccessToken,
   ActiveDirectoryAzCli, ActiveDirectoryDeviceCode,
   ActiveDirectoryWorkloadIdentity,
   ActiveDirectoryClientAssertion,
   ActiveDirectoryAzurePipelines,
   ActiveDirectoryEnvironment,
   ActiveDirectoryAzureDeveloperCli, SqlPassword

-c,--batch-terminator
   Specifies the batch terminator. The default value is GO

-z,--change-password
   New password

-Z,--change-password-exit
   New password and exit

-R,--client-regional-setting
   Provided for backward compatibility. Client regional
   settings are not used

-s,--column-separator
   Specifies the column separator character. Sets the
   SQLCMDCOLSEP variable.

-d,--database-name
   This option sets the sqlcmd scripting variable
   SQLCMDDBNAME. This parameter specifies the initial
   database. The default is your login's default-database
   property. If the database does not exist, an error
   message is generated and sqlcmd exits

-A,--dedicated-admin-connection
   Dedicated administrator connection

-X,--disable-cmd-and-warn
   -X[1] Disables commands that might compromise system
   security. Passing 1 tells sqlcmd to exit when disabled
   commands are run.

-x,--disable-variable-substitution
   Causes sqlcmd to ignore scripting variables. This parameter
   is useful when a script contains many INSERT statements
   that may contain strings that have the same format as
   regular variables, such as $(variable_name)

   --driver-logging-level
   Level of mssql driver messages to print

-e,--echo-input
   Echo input

-g,--enable-column-encryption
   Enable column encryption

-I,--enable-quoted-identifiers
   Provided for backward compatibility. Quoted identifiers are
   always enabled

-N,--encrypt-connection
   This switch is used by the client to request an encrypted
   connection

-m,--error-level
   Controls which error messages are sent to stdout. Messages
   that have severity level greater than or equal to this
   level are sent

-V,--error-severity-level
   Controls the severity level that is used to set the
   ERRORLEVEL variable on exit

-r,--errors-to-stderr
   -r[0 | 1] Redirects error messages with severity >= 11
   output to stderr. Pass 1 to to redirect all errors
   including PRINT.

-b,--exit-on-error
   Specifies that sqlcmd exits and returns a DOS ERRORLEVEL
   value when an error occurs

-Y,--fixed-type-width
   Sets the sqlcmd scripting variable SQLCMDMAXFIXEDTYPEWIDTH

-h,--headers
   Specifies the number of rows to print between the column
   headings. Use -h-1 to specify that headers not be
   printed

-?,--help
   -? shows this syntax summary, --help shows modern sqlcmd
   sub-command help

-F,--host-name-in-certificate
   Specifies the host name in the server certificate.

-q,--initial-query
   Executes a query when sqlcmd starts, but does not exit
   sqlcmd when the query has finished running.
   Multiple-semicolon-delimited queries can be executed

-i,--input-file
   Identifies one or more files that contain batches of SQL
   statements. If one or more files do not exist, sqlcmd
   will exit. Mutually exclusive with -Q/-q

-L,--list-servers
   -L[c] List servers. Pass c to omit 'Servers:' output.

-l,--login-timeOut
   Specifies the number of seconds before a sqlcmd login to
   the go-mssqldb driver times out when you try to connect
   to a server. This option sets the sqlcmd scripting
   variable SQLCMDLOGINTIMEOUT. The default value is 30. 0
   means infinite

-M,--multi-subnet-failover
   Provided for backward compatibility. Sqlcmd always
   optimizes detection of the active replica of a SQL
   Failover Cluster

-o,--output-file
   Identifies the file that receives output from sqlcmd

-a,--packet-size
   Requests a packet of a different size. This option sets the
   sqlcmd scripting variable SQLCMDPACKETSIZE. packet_size
   must be a value between 512 and 32767. The default =
   4096. A larger packet size can enhance performance for
   execution of scripts that have lots of SQL statements
   between GO commands. You can request a larger packet
   size. However, if the request is denied, sqlcmd uses the
   server default for packet size

-P,--password
   Password

-Q,--query
   Executes a query when sqlcmd starts and then immediately
   exits sqlcmd. Multiple-semicolon-delimited queries can
   be executed

-t,--query-timeout
   Query timeout

-k,--remove-control-characters
   -k [1|2] Remove control characters from output. Pass 1 to
   substitute a space per character, 2 for a space per
   consecutive characters

-w,--screen-width
   Specifies the screen width for output

-S,--server
   [[tcp:]|[lpc:]|[np:]]server[\instance_name][,port]
   Specifies the instance of SQL Server to which to
   connect. It sets the sqlcmd scripting variable
   SQLCMDSERVER.

   --trace-file
   Write runtime trace to the specified file. Only for
   advanced debugging.

-W,--trim-spaces
   Remove trailing spaces from a column

-C,--trust-server-certificate
   Implicitly trust the server certificate without validation

-u,--unicode-output-file
   Specifies that all output files are encoded with
   little-endian Unicode

-G,--use-aad
   Tells sqlcmd to use ActiveDirectory authentication. If no
   user name is provided, authentication method
   ActiveDirectoryDefault is used. If a password is
   provided, ActiveDirectoryPassword is used. Otherwise
   ActiveDirectoryInteractive is used

-E,--use-trusted-connection
   Uses a trusted connection instead of using a user name and
   password to sign in to SQL Server, ignoring any
   environment variables that define user name and password

-U,--user-name
   The login name or contained database user name. For
   contained database users, you must provide the database
   name option

-y,--variable-type-width
   Sets the sqlcmd scripting variable SQLCMDMAXVARTYPEWIDTH

-v,--variables
   Creates a sqlcmd scripting variable that can be used in a
   sqlcmd script. Enclose the value in quotation marks if
   the value contains spaces. You can specify multiple
   var=values values. If there are errors in any of the
   values specified, sqlcmd generates an error message and
   then exits

   --version
   Print version information and exit

   --vertical
   Prints the output in vertical format. This option sets the
   sqlcmd scripting variable SQLCMDFORMAT to 'vert'. The
   default is false

-H,--workstation-name
   This option sets the sqlcmd scripting variable
   SQLCMDWORKSTATION. The workstation name is listed in the
   hostname column of the sys.sysprocesses catalog view and
   can be returned using the stored procedure sp_who. If
   this option is not specified, the default is the current
   computer name. This name can be used to identify
   different sqlcmd sessions

step 2 - SQL Server 2025 構成マネージャー での設定変更

SQL Server の default portは 1433 のようですが、インストール直後の状態では、 tcp接続できない為、SQL Server 2025 構成マネージャー での設定変更します。

SQLEXPRESSのプロトコルで、名前付きパイプ、TCP/IPを有効化します

TCP/IPを右クリックし、プロパティ → IPアドレスタブから、 IPALLのTCPポートへ 1433 を入力し、SQL Serverのサービスを再起動します。

step 3 - sqlcmd.exe で接続

先程の設定で、次のように sqlcmd を用い、tcpで接続できるようになります。

DOS> sqlcmd -S tcp:localhost,1433 -E
1>

接続できていない場合、次のようなエラーとなります。

DOS> sqlcmd -S tcp:localhost,1433 -E
unable to open tcp connection with host 'localhost:1433':
    dial tcp 127.0.0.1:1433: connectex: No connection could be
    made because the target machine actively refused it.

sqlcmdでは、tcp以外での接続もできますので、その例を以下に記載します

DOS> sqlcmd -S lpc:.\SQLEXPRESS -E -C
1>
DOS> sqlcmd -S np:\\.\pipe\SQLLocal\SQLEXPRESS -E -C
1>
DOS> sqlcmd -S .\SQLEXPRESS -E -C
1>

Microsoft 365 Apps と Visio 2016 の同居クイックインストール

上記urlによれば、Microsoft 365 Apps と Visio 2016 は クイック実行インストールで、同じPCへ同居インストールできるらしい。

step1 - Office 展開ツール (ODT) のダウンロード

上記のurlにも記載されていますが、 https://www.microsoft.com/en-us/download/details.aspx?id=49117 より、officedeploymenttool_xxxxx-xxxxx.exe をダウンロード & 解凍します。

すると、setup.exe と configuration-Office365-x64.xml が現れ、後程、setup.exe を使用します。

step2 - Office カスタマイズ ツール で xml の作成

先程、ダウンロード & 解凍した configuration-Office365-x64.xml の代わりとなる xml 構成ファイルを次のurlで作成します

https://config.office.com/deploymentsettings

私の場合のポイントは以下

更新チャネルは、m365のexcelと合せる

プロダクトキーは 手持ちのvisioのもの

step3 - setup.exeと xml構成ファイルで インストール

コマンドラインから「setup.exe /configure ~.xml」でも構いませんが、 私の場合、次のようなbatファイルから実行し、インストールしました。

@echo off

:: 管理権限の確認
for /f "tokens=3 delims=\ " %%i in ('whoami /groups^|find "Mandatory"') do set LEVEL=%%i
::echo 権限=%LEVEL%

if "%LEVEL%"=="High" (
    GOTO :SET1
) else (
    GOTO :SET99
)

::-----------------------
:SET1
:: ------実行コマンド----

::MS365のインストール
echo Visio のインストールを開始
"%~dp0setup.exe" /configure  "%~dp0visio_20251211.xml"
echo Visio のインストール完了

proxy配下における huggingface_hub for python の ssl エラー

内部的には、requests for python を利用していますので、 一時的に python3.11/Lib/site-packages/huggingface_hub/utils/_http.py の 306行目にある以下に verify=False を加えることで回避できます。

OLD) response = session.request(method=method, url=url, **kwargs)
NEW) response = session.request(method=method, url=url, **kwargs, verify=False)

ただし、上記の verify=False だけでは、実行時に以下のwarningが表示されますので _http.py に urllib3.disable_warnings(InsecureRequestWarning) 等の3行も加えておくとよいです。

python3.11\Lib\site-packages\urllib3\connectionpool.py:1097:
InsecureRequestWarning: Unverified HTTPS request is being made to host 'huggingface.co'.
Adding certificate verification is strongly advised.
See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
  warnings.warn(
import urllib3
from urllib3.exceptions import InsecureRequestWarning
urllib3.disable_warnings(InsecureRequestWarning)

pip.pyz for python による pip 実行

proxy配下にあるwindows環境で、embeddable python (portable版 python) に対し、 get-pip.py により、pip コマンドの install を試みたところ、以下のエラー。

( get-pip.py に対しては --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org オプションも使用できず )

DOS> python3.11\python.exe get-pip.py
ERROR: Could not install packages due to an OSError:
Could not find a suitable TLS CA certificate bundle, invalid path: False

https://pip.pypa.io/en/stable/installation/ を見たところ pip.pyz という実行形式のpip コマンドを発見。 次のように問題なく pip インストールできました。

DOS> python3.11\python.exe pip.pyz install \
   --trusted-host pypi.python.org --trusted-host files.pythonhosted.org \
   --trusted-host pypi.org \
   sentence_transformers

robocopy 実行メモ

rsync を利用することが多く、windowsrobocopy は、あまり知らないので、メモ

参考url

Robocopyの基本動作とコマンドオプション解説

実行例

オプションの意味は、上記の参考urlをご覧ください

DOS> robocopy I:\edge  S:\Iドライブ\edge
  /MIR /S /COPY:DAT /R:1 /COMPRESS
  /XF *.iso *.mp4 *.m4a *.avi *.mov *.m3u *.wmv
  /LOG+:robocopy.0913.log /FP /NP /ETA /TEE
DOS> robocopy I:\940.事務所関連  V:\Iドライブ\940.事務所関連
   *.iso *.mp4 *.m4a *.avi *.mov *.m3u *.wmv
   /MIR /S /COPY:DAT /R:0 /COMPRESS
   /LOG+:robocopy.0913_2.log /FP /NP /ETA /TEE

 ログ ファイル: C:\Users\end0t\robocopy.0913_2.log

-------------------------------------------------------------------------------
   ROBOCOPY     ::     Windows の堅牢性の高いファイル コピー
-------------------------------------------------------------------------------

  開始: 2025年9月14日 6:35:26
   コピー元 : I:\930.事務関係\
     コピー先 : V:\Iドライブ\930.事務関係\

    ファイル: *.iso
            *.mp4
            *.m4a
            *.avi
            *.mov
            *.m3u
            *.wmv

  オプション: /FP /TEE /S /DCOPY:DA /COPY:DAT /PURGE /MIR /NP /ETA /COMPRESS /R:0 /W:30
------------------------------------------------------------------------------
                           0    I:\930.事務関係\
【略】              
------------------------------------------------------------------------------

                  合計  コピー済み   スキップ    不一致     失敗    Extras
   ディレクトリ:    33        32         1         0         0         0
     ファイル:       0         0         0         0         0         0
      バイト:        0         0         0         0         0         0
       時刻:   0:00:07   0:00:00                       0:00:00   0:00:07
   終了: 2025年9月14日 6:35:34