Imports System.Data.SqlClient
Module Module1
Sub Main()
Dim connectionString1 = "YOUR FIRST CONNECTIONSTRING HERE"
Dim connectionString2 = "YOUR SECOND CONNECTIONSTRING HERE"
Using connection1 = New SqlConnection(connectionString1)
connection1.Open()
Using command = connection1.CreateCommand()
command.CommandText = "CREATE TABLE #T (Name VARCHAR(64))"
command.ExecuteNonQuery()
End Using
Using connection2 = New SqlConnection(connectionString2)
connection2.Open()
Using command = connection2.CreateCommand()
command.CommandText = "SELECT Name FROM Table2"
Using reader = command.ExecuteReader()
Using bulkCopy = New SqlBulkCopy(connection1)
bulkCopy.DestinationTableName = "#T"
bulkCopy.BatchSize = 10000
bulkCopy.ColumnMappings.Add(0, "Name")
bulkCopy.WriteToServer(reader)
End Using
End Using
End Using
End Using
Using command = connection1.CreateCommand()
command.CommandText = "SELECT Table1.Name FROM Table1 INNER JOIN #T ON Table1.Name = #T.Name"
Using reader = command.ExecuteReader()
' Do what you want with the joined data here,
' if you like you can BulkCopy it on another connection
End Using
End Using
End Using
End Sub
End Module
这打印subreddits&我想弄清楚它打印出来的数量,或者我是否可以打印出一定数量。谢谢!
答案 0 :(得分:0)
import requests
r = requests.get('http://www.reddit.com/reddits.json', headers= {'User-Agent': 'me'})
data = r.json()
print(len(data['data']['children']))
JSON的结构很复杂,所以我不完全确定你想要计算什么,但['data']['children']
似乎是subreddits的根。