Re: [julia-users] Re: Questions regarding to SQLite

2016-05-25 Thread SHORE SHEN
oh thank you!!! will test asap, thanks so much

在 2016年5月26日星期四 UTC+8下午1:17:40,Jacob Quinn写道:
>
> Yep,
>
> like I said, just switch your "using" statements around to make sure 
> "using DataFrames" comes before "using SQLite"
>
> -Jacob
>
> On Wed, May 25, 2016 at 11:15 PM, SHORE SHEN  > wrote:
>
>> Hi:
>>
>> heres my codes:
>>
>> using SQLite
>> using DataFrames
>>
>> db=SQLite.DB("test3.db")
>> query(db,"create table emp (id integer, name text)")
>> query(db,"insert into emp (id, name) values(1,'jay')")
>> query(db,"insert into emp (id, name) values(2,'kay')")
>> query(db,"insert into emp (id, name) values(4,'vay')")
>>
>> y=SQLite.query(db,"select * from emp")
>> z=Data.stream!(SQLite.Source(db,"select * from emp"), Data.Table)
>>
>> DataFrame(z)
>>
>> and the error reported:
>>
>> MethodError: `convert` has no method matching 
>> convert(::Type{DataFrames.DataFrame}, 
>> ::DataStreams.Data.Table{Array{NullableArrays.NullableArray{T,1},1}})
>> This may have arisen from a call to the constructor 
>> DataFrames.DataFrame(...),
>> since type constructors fall back to convert methods.WARNING: Error 
>> showing method candidates, aborted
>>
>>  in call at essentials.jl:56
>>  in include_string at C:\Users\shoren\.julia\v0.4\CodeTools\src\eval.jl:28
>>  in include_string at C:\Users\shoren\.julia\v0.4\CodeTools\src\eval.jl:32
>>  [inlined code] from C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:39
>>  in anonymous at C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:62
>>  in withpath at C:\Users\shoren\.julia\v0.4\Requires\src\require.jl:37
>>  in withpath at C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:53
>>  [inlined code] from C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:61
>>  in anonymous at task.jl:58
>>
>> 在 2016年5月26日星期四 UTC+8下午12:45:00,Jacob Quinn写道:
>>>
>>> Make sure you do
>>>
>>> using DataFrames
>>> using SQLite
>>>
>>> in that order in a fresh Julia session to ensure the conversion methods 
>>> get defined (when you load the SQLite package, it checks if DataFrames has 
>>> already been loaded to define the conversion routines).
>>>
>>> -Jacob
>>>
>>>
>>> On Wed, May 25, 2016 at 10:43 PM, SHORE SHEN  
>>> wrote:
>>>
 Hi Alex

 thanks so much for your reply, I tried out the method but it fails when 
 using DataFrame(Data.stream!(source, Data.Table)) commend. It reported 
 no such method error msg as follow:

 MethodError: `convert` has no method matching 
 convert(::Type{DataFrames.DataFrame}, 
 ::DataStreams.Data.Table{Array{NullableArrays.NullableArray{T,1},1}})
 This may have arisen from a call to the constructor 
 DataFrames.DataFrame(...),
 since type constructors fall back to convert methods.WARNING: Error 
 showing method candidates, aborted

  in call at essentials.jl:56
  in include_string at 
 C:\Users\shoren\.julia\v0.4\CodeTools\src\eval.jl:28
  in include_string at 
 C:\Users\shoren\.julia\v0.4\CodeTools\src\eval.jl:32
  [inlined code] from C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:39
  in anonymous at C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:62
  in withpath at C:\Users\shoren\.julia\v0.4\Requires\src\require.jl:37
  in withpath at C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:53
  [inlined code] from C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:61
  in anonymous at task.jl:58

 在 2016年5月26日星期四 UTC+8上午12:30:52,Alex Mellnik写道:

>
> Yes to both!  
>
> For the first one, you want to use Data.stream! to get a Data.Table 
> from the result set, and then convert it to a DataFrame.  For the second 
> you need to do the opposite.  I generally work with DataFrames so I wrote 
> two convenience functions for doing this, which should give you an idea 
> of 
> how to go about it:
>
> function queryToDF(db, query)
> source = SQLite.Source(db, query)
> return DataFrame(Data.stream!(source, Data.Table))
> end
>
> function dfToDB(db, df, table)
> sink = SQLite.Sink(Data.Table(df), db, table)
> Data.stream!(Data.Table(df), sink)
> end
>
> Cheers -A
>
> On Wednesday, May 25, 2016 at 2:54:26 AM UTC-7, SHORE SHEN wrote:
>>
>> Hello
>>
>> Im trying out the sqlite package in julia, I got the following 2 
>> questions:
>>
>> 1, the query will result in a type of SQLite.ResultSet, if i can 
>> output dataframe or dataarry type?
>>
>> 2, if i have a dataframe or dataarray type, would i be able to put it 
>> into the database table?
>>
>> thanks a lot!
>>
>
>>>
>

Re: [julia-users] Re: Questions regarding to SQLite

2016-05-25 Thread Jacob Quinn
Yep,

like I said, just switch your "using" statements around to make sure "using
DataFrames" comes before "using SQLite"

-Jacob

On Wed, May 25, 2016 at 11:15 PM, SHORE SHEN 
wrote:

> Hi:
>
> heres my codes:
>
> using SQLite
> using DataFrames
>
> db=SQLite.DB("test3.db")
> query(db,"create table emp (id integer, name text)")
> query(db,"insert into emp (id, name) values(1,'jay')")
> query(db,"insert into emp (id, name) values(2,'kay')")
> query(db,"insert into emp (id, name) values(4,'vay')")
>
> y=SQLite.query(db,"select * from emp")
> z=Data.stream!(SQLite.Source(db,"select * from emp"), Data.Table)
>
> DataFrame(z)
>
> and the error reported:
>
> MethodError: `convert` has no method matching
> convert(::Type{DataFrames.DataFrame},
> ::DataStreams.Data.Table{Array{NullableArrays.NullableArray{T,1},1}})
> This may have arisen from a call to the constructor
> DataFrames.DataFrame(...),
> since type constructors fall back to convert methods.WARNING: Error
> showing method candidates, aborted
>
>  in call at essentials.jl:56
>  in include_string at C:\Users\shoren\.julia\v0.4\CodeTools\src\eval.jl:28
>  in include_string at C:\Users\shoren\.julia\v0.4\CodeTools\src\eval.jl:32
>  [inlined code] from C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:39
>  in anonymous at C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:62
>  in withpath at C:\Users\shoren\.julia\v0.4\Requires\src\require.jl:37
>  in withpath at C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:53
>  [inlined code] from C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:61
>  in anonymous at task.jl:58
>
> 在 2016年5月26日星期四 UTC+8下午12:45:00,Jacob Quinn写道:
>>
>> Make sure you do
>>
>> using DataFrames
>> using SQLite
>>
>> in that order in a fresh Julia session to ensure the conversion methods
>> get defined (when you load the SQLite package, it checks if DataFrames has
>> already been loaded to define the conversion routines).
>>
>> -Jacob
>>
>>
>> On Wed, May 25, 2016 at 10:43 PM, SHORE SHEN 
>> wrote:
>>
>>> Hi Alex
>>>
>>> thanks so much for your reply, I tried out the method but it fails when
>>> using DataFrame(Data.stream!(source, Data.Table)) commend. It reported
>>> no such method error msg as follow:
>>>
>>> MethodError: `convert` has no method matching
>>> convert(::Type{DataFrames.DataFrame},
>>> ::DataStreams.Data.Table{Array{NullableArrays.NullableArray{T,1},1}})
>>> This may have arisen from a call to the constructor
>>> DataFrames.DataFrame(...),
>>> since type constructors fall back to convert methods.WARNING: Error
>>> showing method candidates, aborted
>>>
>>>  in call at essentials.jl:56
>>>  in include_string at
>>> C:\Users\shoren\.julia\v0.4\CodeTools\src\eval.jl:28
>>>  in include_string at
>>> C:\Users\shoren\.julia\v0.4\CodeTools\src\eval.jl:32
>>>  [inlined code] from C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:39
>>>  in anonymous at C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:62
>>>  in withpath at C:\Users\shoren\.julia\v0.4\Requires\src\require.jl:37
>>>  in withpath at C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:53
>>>  [inlined code] from C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:61
>>>  in anonymous at task.jl:58
>>>
>>> 在 2016年5月26日星期四 UTC+8上午12:30:52,Alex Mellnik写道:
>>>

 Yes to both!

 For the first one, you want to use Data.stream! to get a Data.Table
 from the result set, and then convert it to a DataFrame.  For the second
 you need to do the opposite.  I generally work with DataFrames so I wrote
 two convenience functions for doing this, which should give you an idea of
 how to go about it:

 function queryToDF(db, query)
 source = SQLite.Source(db, query)
 return DataFrame(Data.stream!(source, Data.Table))
 end

 function dfToDB(db, df, table)
 sink = SQLite.Sink(Data.Table(df), db, table)
 Data.stream!(Data.Table(df), sink)
 end

 Cheers -A

 On Wednesday, May 25, 2016 at 2:54:26 AM UTC-7, SHORE SHEN wrote:
>
> Hello
>
> Im trying out the sqlite package in julia, I got the following 2
> questions:
>
> 1, the query will result in a type of SQLite.ResultSet, if i can
> output dataframe or dataarry type?
>
> 2, if i have a dataframe or dataarray type, would i be able to put it
> into the database table?
>
> thanks a lot!
>

>>


Re: [julia-users] Re: Questions regarding to SQLite

2016-05-25 Thread SHORE SHEN
Hi:

heres my codes:

using SQLite
using DataFrames

db=SQLite.DB("test3.db")
query(db,"create table emp (id integer, name text)")
query(db,"insert into emp (id, name) values(1,'jay')")
query(db,"insert into emp (id, name) values(2,'kay')")
query(db,"insert into emp (id, name) values(4,'vay')")

y=SQLite.query(db,"select * from emp")
z=Data.stream!(SQLite.Source(db,"select * from emp"), Data.Table)

DataFrame(z)

and the error reported:

MethodError: `convert` has no method matching 
convert(::Type{DataFrames.DataFrame}, 
::DataStreams.Data.Table{Array{NullableArrays.NullableArray{T,1},1}})
This may have arisen from a call to the constructor 
DataFrames.DataFrame(...),
since type constructors fall back to convert methods.WARNING: Error showing 
method candidates, aborted

 in call at essentials.jl:56
 in include_string at C:\Users\shoren\.julia\v0.4\CodeTools\src\eval.jl:28
 in include_string at C:\Users\shoren\.julia\v0.4\CodeTools\src\eval.jl:32
 [inlined code] from C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:39
 in anonymous at C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:62
 in withpath at C:\Users\shoren\.julia\v0.4\Requires\src\require.jl:37
 in withpath at C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:53
 [inlined code] from C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:61
 in anonymous at task.jl:58

在 2016年5月26日星期四 UTC+8下午12:45:00,Jacob Quinn写道:
>
> Make sure you do
>
> using DataFrames
> using SQLite
>
> in that order in a fresh Julia session to ensure the conversion methods 
> get defined (when you load the SQLite package, it checks if DataFrames has 
> already been loaded to define the conversion routines).
>
> -Jacob
>
>
> On Wed, May 25, 2016 at 10:43 PM, SHORE SHEN  > wrote:
>
>> Hi Alex
>>
>> thanks so much for your reply, I tried out the method but it fails when 
>> using DataFrame(Data.stream!(source, Data.Table)) commend. It reported 
>> no such method error msg as follow:
>>
>> MethodError: `convert` has no method matching 
>> convert(::Type{DataFrames.DataFrame}, 
>> ::DataStreams.Data.Table{Array{NullableArrays.NullableArray{T,1},1}})
>> This may have arisen from a call to the constructor 
>> DataFrames.DataFrame(...),
>> since type constructors fall back to convert methods.WARNING: Error 
>> showing method candidates, aborted
>>
>>  in call at essentials.jl:56
>>  in include_string at C:\Users\shoren\.julia\v0.4\CodeTools\src\eval.jl:28
>>  in include_string at C:\Users\shoren\.julia\v0.4\CodeTools\src\eval.jl:32
>>  [inlined code] from C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:39
>>  in anonymous at C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:62
>>  in withpath at C:\Users\shoren\.julia\v0.4\Requires\src\require.jl:37
>>  in withpath at C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:53
>>  [inlined code] from C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:61
>>  in anonymous at task.jl:58
>>
>> 在 2016年5月26日星期四 UTC+8上午12:30:52,Alex Mellnik写道:
>>
>>>
>>> Yes to both!  
>>>
>>> For the first one, you want to use Data.stream! to get a Data.Table from 
>>> the result set, and then convert it to a DataFrame.  For the second you 
>>> need to do the opposite.  I generally work with DataFrames so I wrote two 
>>> convenience functions for doing this, which should give you an idea of how 
>>> to go about it:
>>>
>>> function queryToDF(db, query)
>>> source = SQLite.Source(db, query)
>>> return DataFrame(Data.stream!(source, Data.Table))
>>> end
>>>
>>> function dfToDB(db, df, table)
>>> sink = SQLite.Sink(Data.Table(df), db, table)
>>> Data.stream!(Data.Table(df), sink)
>>> end
>>>
>>> Cheers -A
>>>
>>> On Wednesday, May 25, 2016 at 2:54:26 AM UTC-7, SHORE SHEN wrote:

 Hello

 Im trying out the sqlite package in julia, I got the following 2 
 questions:

 1, the query will result in a type of SQLite.ResultSet, if i can output 
 dataframe or dataarry type?

 2, if i have a dataframe or dataarray type, would i be able to put it 
 into the database table?

 thanks a lot!

>>>
>

Re: [julia-users] Re: Questions regarding to SQLite

2016-05-25 Thread Jacob Quinn
Make sure you do

using DataFrames
using SQLite

in that order in a fresh Julia session to ensure the conversion methods get
defined (when you load the SQLite package, it checks if DataFrames has
already been loaded to define the conversion routines).

-Jacob


On Wed, May 25, 2016 at 10:43 PM, SHORE SHEN 
wrote:

> Hi Alex
>
> thanks so much for your reply, I tried out the method but it fails when
> using DataFrame(Data.stream!(source, Data.Table)) commend. It reported no
> such method error msg as follow:
>
> MethodError: `convert` has no method matching
> convert(::Type{DataFrames.DataFrame},
> ::DataStreams.Data.Table{Array{NullableArrays.NullableArray{T,1},1}})
> This may have arisen from a call to the constructor
> DataFrames.DataFrame(...),
> since type constructors fall back to convert methods.WARNING: Error
> showing method candidates, aborted
>
>  in call at essentials.jl:56
>  in include_string at C:\Users\shoren\.julia\v0.4\CodeTools\src\eval.jl:28
>  in include_string at C:\Users\shoren\.julia\v0.4\CodeTools\src\eval.jl:32
>  [inlined code] from C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:39
>  in anonymous at C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:62
>  in withpath at C:\Users\shoren\.julia\v0.4\Requires\src\require.jl:37
>  in withpath at C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:53
>  [inlined code] from C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:61
>  in anonymous at task.jl:58
>
> 在 2016年5月26日星期四 UTC+8上午12:30:52,Alex Mellnik写道:
>
>>
>> Yes to both!
>>
>> For the first one, you want to use Data.stream! to get a Data.Table from
>> the result set, and then convert it to a DataFrame.  For the second you
>> need to do the opposite.  I generally work with DataFrames so I wrote two
>> convenience functions for doing this, which should give you an idea of how
>> to go about it:
>>
>> function queryToDF(db, query)
>> source = SQLite.Source(db, query)
>> return DataFrame(Data.stream!(source, Data.Table))
>> end
>>
>> function dfToDB(db, df, table)
>> sink = SQLite.Sink(Data.Table(df), db, table)
>> Data.stream!(Data.Table(df), sink)
>> end
>>
>> Cheers -A
>>
>> On Wednesday, May 25, 2016 at 2:54:26 AM UTC-7, SHORE SHEN wrote:
>>>
>>> Hello
>>>
>>> Im trying out the sqlite package in julia, I got the following 2
>>> questions:
>>>
>>> 1, the query will result in a type of SQLite.ResultSet, if i can output
>>> dataframe or dataarry type?
>>>
>>> 2, if i have a dataframe or dataarray type, would i be able to put it
>>> into the database table?
>>>
>>> thanks a lot!
>>>
>>


[julia-users] Re: Questions regarding to SQLite

2016-05-25 Thread SHORE SHEN
Hi Alex

thanks so much for your reply, I tried out the method but it fails when 
using DataFrame(Data.stream!(source, Data.Table)) commend. It reported no 
such method error msg as follow:

MethodError: `convert` has no method matching 
convert(::Type{DataFrames.DataFrame}, 
::DataStreams.Data.Table{Array{NullableArrays.NullableArray{T,1},1}})
This may have arisen from a call to the constructor 
DataFrames.DataFrame(...),
since type constructors fall back to convert methods.WARNING: Error showing 
method candidates, aborted

 in call at essentials.jl:56
 in include_string at C:\Users\shoren\.julia\v0.4\CodeTools\src\eval.jl:28
 in include_string at C:\Users\shoren\.julia\v0.4\CodeTools\src\eval.jl:32
 [inlined code] from C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:39
 in anonymous at C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:62
 in withpath at C:\Users\shoren\.julia\v0.4\Requires\src\require.jl:37
 in withpath at C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:53
 [inlined code] from C:\Users\shoren\.julia\v0.4\Atom\src\eval.jl:61
 in anonymous at task.jl:58

在 2016年5月26日星期四 UTC+8上午12:30:52,Alex Mellnik写道:
>
>
> Yes to both!  
>
> For the first one, you want to use Data.stream! to get a Data.Table from 
> the result set, and then convert it to a DataFrame.  For the second you 
> need to do the opposite.  I generally work with DataFrames so I wrote two 
> convenience functions for doing this, which should give you an idea of how 
> to go about it:
>
> function queryToDF(db, query)
> source = SQLite.Source(db, query)
> return DataFrame(Data.stream!(source, Data.Table))
> end
>
> function dfToDB(db, df, table)
> sink = SQLite.Sink(Data.Table(df), db, table)
> Data.stream!(Data.Table(df), sink)
> end
>
> Cheers -A
>
> On Wednesday, May 25, 2016 at 2:54:26 AM UTC-7, SHORE SHEN wrote:
>>
>> Hello
>>
>> Im trying out the sqlite package in julia, I got the following 2 
>> questions:
>>
>> 1, the query will result in a type of SQLite.ResultSet, if i can output 
>> dataframe or dataarry type?
>>
>> 2, if i have a dataframe or dataarray type, would i be able to put it 
>> into the database table?
>>
>> thanks a lot!
>>
>

[julia-users] Re: Questions regarding to SQLite

2016-05-25 Thread Alex Mellnik

Yes to both!  

For the first one, you want to use Data.stream! to get a Data.Table from 
the result set, and then convert it to a DataFrame.  For the second you 
need to do the opposite.  I generally work with DataFrames so I wrote two 
convenience functions for doing this, which should give you an idea of how 
to go about it:

function queryToDF(db, query)
source = SQLite.Source(db, query)
return DataFrame(Data.stream!(source, Data.Table))
end

function dfToDB(db, df, table)
sink = SQLite.Sink(Data.Table(df), db, table)
Data.stream!(Data.Table(df), sink)
end

Cheers -A

On Wednesday, May 25, 2016 at 2:54:26 AM UTC-7, SHORE SHEN wrote:
>
> Hello
>
> Im trying out the sqlite package in julia, I got the following 2 questions:
>
> 1, the query will result in a type of SQLite.ResultSet, if i can output 
> dataframe or dataarry type?
>
> 2, if i have a dataframe or dataarray type, would i be able to put it into 
> the database table?
>
> thanks a lot!
>