The other thing to consider, for SQL Server exports, is that you should be
using the SqlBulkCopy class (or bcp.exe) to pull data out of your SQL
Server without doing terrible terrible things to your SQL Server
performance. You'll be better served by pushing data in stages rather than
attempting to stream data into Riak directly from SQL Server, even with
some intermediary transformation in between you'll still put some load on
SQL Server that could easily be avoided.

---
Jeremiah Peschka
Founder, Brent Ozar Unlimited
Microsoft SQL Server MVP


On Thu, Nov 1, 2012 at 1:18 PM, Jayson Barley <jayson.bar...@gmail.com>wrote:

>  What you are going to want to do is to get the code from the T4 link. You
> will use that to generate your POCO classes. Optionally you can create the
> classes by hand since there are only a few of them. Create a .NET
> application, C# in this case. Include the POCO classes into your main app
> along with the Dapper assembly. The below code should be fairly accurate. I
> typed this in gmail so I can't guarantee it will compile.
>
> // Careful with the size. With tables that have several million rows you
> may exceed the max length
> JavaScriptSerializer ser = new JavaScriptSerializer(){MaxJsonLength =
> Int32.MaxValue};
> StringBuilder json = new StringBuilder();
> string connectionString = @"Data Source=DbServer;Initial
> Catalog=DbName;Integrated Security=True";
> // RIAK url to send data to
> string url = "http://127.0.0.1:8091/riak/goog/";;
> // Iterate through your tables.
> foreach(var table in Tables)
> {
>     using(var connection = new SqlConnection(connectionString))
>     {
>         connection.Open();
>         // This is your dapper query that converts the results to your
> classes
>         var results = connection.Query<SomeTable>(@"SELECT * FROM
> SomeTable;").ToList();
>
>         ser.Serialize<SomeTable>(json);
>
>         WebRequest request = WebRequest.Create(url);
>         request.Method = "POST";
>         request.ContentType ="application/json;charset=utf-8";
>         ((HttpWebRequest)request).KeepAlive = false;
>         byte[] byteData = Encoding.UTF8.GetBytes(json.ToString());
>         request.ContentLength = byteData.Length;
>         using (var postStream = request.GetRequestStream())
>         {
>             postStream.Write(byteData, 0, byteData.Length);
>             postStream.Close();
>
>         }
>     }
> }
>
>
> On Thu, Nov 1, 2012 at 12:41 PM, Dmitri Zagidulin <dzagidu...@basho.com>wrote:
>
>> Ah, ok.
>> Then I highly recommend following Jayson Barley's approach, in the
>> previous email. Query SQL server, compose a POCO type object, serialize it
>> to JSON, and store it in Riak either via the C++/C# client, or just use an
>> HTTP client and PUT/POST it over http.
>>
>>
>> On Thu, Nov 1, 2012 at 3:37 PM, Kevin Burton <rkevinbur...@charter.net>wrote:
>>
>>> OK. ****
>>>
>>> ** **
>>>
>>> My preferred programming language is C++ or more recently C#. I have
>>> done some Java programming but that was a while back. When I have played
>>> with JavaScript it was always in the context of Microsoft’s version of
>>> JavaScript.****
>>>
>>> ** **
>>>
>>> I would like to migrate about 5 tables. Our database is very
>>> unstructured so there are few to no relationships so I don’t plan on
>>> migrating relationships.****
>>>
>>> ** **
>>>
>>> The migration is really for a demo where I do a query on SQL Server and
>>> as close as I can (based on the model that I create) retrieve the same type
>>> of information using Riak and compare the performance. Then once I have a
>>> basic apples to apples comparison I can show the other salient features of
>>> Riak.****
>>>
>>> ** **
>>>
>>> *From:* riak-users [mailto:riak-users-boun...@lists.basho.com] *On
>>> Behalf Of *Dmitri Zagidulin
>>> *Sent:* Thursday, November 01, 2012 2:18 PM
>>>
>>> *To:* riak-users
>>> *Subject:* Re: Import tables/data from Microsoft SQL Server****
>>>
>>> ** **
>>>
>>> Possibly. Let's step back for a second, however. Node.js might not be a
>>> good fit for your migration script needs.
>>>
>>> A couple of questions:
>>>
>>> 1) What's your preferred programming language? Java, python, javascript,
>>> etc?
>>>
>>> 2) What kind of data are you trying to migrate? (one table or many? what
>>> kind of joins/relationships?)
>>>
>>> 3) What sort of use case/application is this migration for? ****
>>>
>>> On Thu, Nov 1, 2012 at 3:15 PM, Kevin Burton <rkevinbur...@charter.net>
>>> wrote:****
>>>
>>> In this case the “server” is the Microsoft SQL Server. Right? So I need
>>> to have IIS running on the same machine as the SQL Server?****
>>>
>>>  ****
>>>
>>> *From:* riak-users [mailto:riak-users-boun...@lists.basho.com] *On
>>> Behalf Of *Dmitri Zagidulin
>>> *Sent:* Thursday, November 01, 2012 2:07 PM
>>> *To:* riak-users****
>>>
>>>
>>> *Subject:* Re: Import tables/data from Microsoft SQL Server****
>>>
>>>  ****
>>>
>>> Node.js http://nodejs.org/ http://en.wikipedia.org/wiki/Nodejs is a
>>> server-side Javascript web application framework.
>>>
>>> It is completely unrelated to Java, and will have to be installed
>>> separately. (It uses its own, javascript-specific package management app
>>> called 'npm' (it's similar to ruby gems and python's eggs), plus has some
>>> dependencies that you'll need to install via apt-get).
>>>
>>> Take a look here, for example, for installation instructions:
>>>
>>> https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
>>> ****
>>>
>>> On Thu, Nov 1, 2012 at 2:53 PM, Kevin Burton <rkevinbur...@charter.net>
>>> wrote:****
>>>
>>> Sorry for the newbie question but is node.js part of the Java
>>> distribution for a Ubuntu Linux Server or do I need to get it as a package?
>>> How is it installed? I am assuming that once node.js is installed then the
>>> code will be just like any other Java app. Right?****
>>>
>>>  ****
>>>
>>> *From:* Jeff Kirkell [mailto:jeff.kirk...@gmail.com]
>>> *Sent:* Thursday, November 01, 2012 1:25 PM****
>>>
>>>
>>> *To:* Kevin Burton
>>> *Cc:* riak-users
>>> *Subject:* Re: Import tables/data from Microsoft SQL Server****
>>>
>>>  ****
>>>
>>> This Microsoft blog post gives a sample how to query the SQL Server****
>>>
>>>
>>> http://blogs.msdn.com/b/sqlphp/archive/2012/06/08/introducing-the-microsoft-driver-for-node-js-for-sql-server.aspx
>>> ****
>>>
>>>  ****
>>>
>>> In the record loop, you use a Riak Node driver like riak-js.****
>>>
>>>  ****
>>>
>>> I can't share the scripts I wrote due to work but I can answer anything
>>> you may have outside of providing the code.****
>>>
>>>  ****
>>>
>>> Thanks,****
>>>
>>> Jeff****
>>>
>>>  ****
>>>
>>> On Thu, Nov 1, 2012 at 2:09 PM, Kevin Burton <rkevinbur...@charter.net>
>>> wrote:****
>>>
>>> Would you mind sharing that app? If you have time since I am not
>>> familiar with Node.js would you mind showing me how you ran it as well as
>>> the source. Thank you.****
>>>
>>>  ****
>>>
>>> *From:* Jeff Kirkell [mailto:jeff.kirk...@gmail.com]
>>> *Sent:* Thursday, November 01, 2012 1:07 PM
>>> *To:* Kevin Burton
>>> *Cc:* riak-users
>>> *Subject:* Re: Import tables/data from Microsoft SQL Server****
>>>
>>>  ****
>>>
>>> There is nothing that I have come across. What I did in the past was run
>>> a quick Node.js app that pulled data out of SQL Server using one of the
>>> available drivers and serialize and write to Riak. It is not perfect, and
>>> may be slow depending on the amount of data but it does work.****
>>>
>>>  ****
>>>
>>> Jeff****
>>>
>>>  ****
>>>
>>> On Thu, Nov 1, 2012 at 1:40 PM, Kevin Burton <rkevinbur...@charter.net>
>>> wrote:****
>>>
>>> I would like some scripts or programming tools that I could use to
>>> transfer existing data held in Microsoft SQL Server databases into Riak. Do
>>> such tools exist?****
>>>
>>>
>>> _______________________________________________
>>> riak-users mailing list
>>> riak-users@lists.basho.com
>>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com****
>>>
>>>  ****
>>>
>>>  ****
>>>
>>>
>>> _______________________________________________
>>> riak-users mailing list
>>> riak-users@lists.basho.com
>>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com****
>>>
>>>  ****
>>>
>>> ** **
>>>
>>
>>
>> _______________________________________________
>> riak-users mailing list
>> riak-users@lists.basho.com
>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>>
>>
>
> _______________________________________________
> riak-users mailing list
> riak-users@lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
>
_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to