SQL ile Toplu Eşitleme
Komut: sqlBulkSynchronize
Kullanılabilir kaynak: < Enterprise>
Veritabanındaki tüm hedef çizelge değerlerinin, kaynak tablodaki değerlerle aynı olması için iki çizelge arasında bir toplu eşitleme işlemi çalıştırır.
Sözdizimi
sqlBulkSynchronize --dataTable(DataTable) --connection(DbConnection) --tablename(String) [--batchsize(Numeric)] [--mappings(String)] [--timeout(TimeSpan)] (Boolean)=value
Girişler
| Komut dosyası | Tasarımcı | Zorunlu | Kabul edilen tipler | Açıklama |
|---|---|---|---|---|
| --dataTable | Veri Tablosu | Zorunlu | Veri Tablosu | Veritabanı tablosuyla eşitleme için başvuru görevi yapacak kaynak veri tablosu. |
| -- bağlantı | Bağlantı | Zorunlu | Veritabanı Bağlantısı | Veritabanı bağlantı değişkeni. Bu bağlantı için aşağıdaki seçeneklere sahip olun: |
| -- çizelgeadı | Tablo Adı | Zorunlu | Metin | Veritabanı tablolarının adı. |
| -- batchsize | Toplu İş Boyutu | İsteğe bağlı | Numara | Her bir toplu işteki bir defada eşitlenen veri miktarına ilişkin sayı. |
| -- eşlemeler | Eşlemeler | İsteğe bağlı | Metin | SQL çizelge değerlerini kullanarak, verili Veri Tablosu kolonlarına ilişkin eşlemeler. Yeni eşlemeler eklerken şu alanları bulacaksınız:- Sütun adı: Eşleştirmek istediğiniz Veri Tablosu sütununun adı;- Sütun numarası: Eşlemek istediğiniz Veri Tablosu sütununun numarası. Kolon numaraları 1 'de başlar;-Adsız alan: SQL çizelge kolonu adına gönderme yapar.Bir değer yalnızca Sütun adı ya da Sütun numarası alanlarından birinde girilmelidir. |
| -- zamanaşımı | Zaman aşımı | İsteğe bağlı | Zaman Aralığı, Sayı, Metin | Bağlantı kurulması için bekleme süresi üst sınırı ve eşitlenecek veriler. |
Çıkışlar
| Komut dosyası | Tasarımcı | Kabul edilen tipler | Açıklama |
|---|---|---|---|
| değer | Başarılı | Boole | Yürütme başarılı olursa "True" değerini, tersi durumda "False" değerini döndürür. |
Örnek
SQL ile Toplu Eşitleme komutu, bir veri tablolarının değerlerini eşler ve MySQL Connection komutuyla bağlı veritabanındaki "kitap" çizelgesiyle eşitlenir. Yürütmeden sonra, Veritabanı tablosundan değerler gerektiği şekilde güncellenir (eklenir, silinir ya da yeni oluşturulur).
defVar --name connection --type DbConnection
defVar --name tableDataBooks --type DataTable
defVar --name fileExcelDataBooks --type Excel
defVar --name tableBooks --type DataTable
// Connect to mysql.
mysqlConnect --connectionstring "Data Source = 127.0.0.1; User ID = root; Password = \" \""
// Create the database "bdTechnology" and the table "book".
sqlExecuteReader --connection ${connection} --statement "CREATE DATABASE bdTechnology; \r\nUSE bdTechnology; \r\nCREATE TABLE book (id INT NOT NULL AUTO_INCREMENT, price DOUBLE, title EXT, author TEXT, publisher TEXT, numPage INT, language CHAR (2), PRIMARY KEY (id)); "
// Download the following file to execute the command.
excelOpen --file "excelTableDataBooksInsert_Synchronize.xlsx" fileExcelDataBooks=value
excelGetTable --file ${fileExcelDataBooks} --getfirstsheet --entiretable --hasheaders tableDataBooks=value
// Inserts data into the database.
sqlBulkInsert --dataTable ${tableDataBooks} --connection ${connection} --tablename book
sqlExecuteReader --connection ${connection} --statement "select * from book;" tableDataBooks=value
logMessage --message "DATABASE AFTER INSERTION: ${tableDataBooks}" --type "Info"
// DATABASE AFTER INSERTION:
// 1 59.99 The Master: How the Search for the Ultimate Machine Learning Algorithm Will Recreate Our World Pedro Domingos Novatec 344 EN
// 2 30 Steve Jobs Walter Isaacson Simon & Schuster 656 EN
// 3 120 Elon Musk: How the billionaire CEO of SpaceX and Tesla is shaping our future Ashlee Vance Intrinsic 416 EN
// 4 200 Brief answers to big questions Stephen Hawking Intrinsic 256 EN
// Download the following file to execute the command.
excelOpen --file "excelTableDataBooksInsert_Synchronize.xlsx" fileExcelDataBooks=value
excelGetTable --file ${fileExcelDataBooks} --getfirstsheet --entiretable --hasheaders tableDataBooks=value
logMessage --message "TABLE TO SYNC: \r\n ${tableDataBooks}" --type "Info"
// TABLE TO SYNC:
// 1 59.99 The Master Algorithm: How the Search for the Ultimate Machine Learning Algorithm Will Recreate Our World Pedro Domingos Novatec 344 EN
// 2 200 Steve Jobs Walter Isaacson Simon & Schuster 656 EN
// 3 120 Elon Musk: How the billionaire CEO of SpaceX and Tesla is shaping our future Ashlee Vance Intrinsic 416 EN
//
// 5 150 Artificial intelligence Peter Norvig GEN LTC 1016 AL
// 6 152 Astrophysics for hasties Neil Degrasse Tyson Planet 192 AL
sqlBulkSynchronize --dataTable ${tableDataBooks} --connection ${connection} --tablename book --mappings "number=1=id,number=2=price,number=3=title,number=4=author,number=5=publisher,number=6=numPage,number=7=language"
sqlExecuteReader --connection ${connection} --statement "SELECT * FROM book" tableBooks=value
logMessage --message "DATABASE AFTER SYNCHRONIZATION: ${tableBooks}" --type "Info"
// DATABASE AFTER SYNCHRONIZATION:
// 1 59.99 The Master Algorithm: How the Search for the Ultimate Machine Learning Algorithm Will Recreate Our World Pedro Domingos Novatec 344 EN
// 2 200 Steve Jobs Walter Isaacson Simon & Schuster 656 EN
// 3 120 Elon Musk: How the billionaire CEO of SpaceX and Tesla is shaping our future Ashlee Vance Intrinsic 416 EN
// 5 150 Artificial intelligence Peter Norvig GEN LTC 1016 AL
// 6 152 Astrophysics for hasties Neil Degrasse Tyson Planet 192 AL
sqlExecute --connection ${connection} --statement "DROP DATABASE bdtechnology"
Dosyayı Karşıdan Yükle
For the script to work properly, you need to download the files and enter their path in the Dosya Yolu parameter of the Office Dosyasını Aç command.