Skip to content

Commit 787055f

Browse files
committed
Fixed a DataFrame id bug and changed the BEGIN TRANSACTION and COMMIT commands to be more inline with the actual inserting (interuptions were causing bugs; fixes issue #2
1 parent 87300d9 commit 787055f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Sqlite.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,12 @@ function createtable(input::TableInput,conn::SqliteDB=sqlitedb;name::String="")
133133
conn == null_SqliteDB && error("[sqlite]: A valid SqliteDB was not specified (and no valid default SqliteDB exists)")
134134
#these 2 calls are for performance
135135
internal_query(conn,"PRAGMA synchronous = OFF")
136-
internal_query(conn,"BEGIN TRANSACTION")
136+
137137
if typeof(input) == DataFrame
138138
r = df2table(input,conn,name)
139139
else
140140
r = 0 # dlm2table(input,conn,name)
141141
end
142-
internal_query(conn,"COMMIT")
143142
internal_query(conn,"PRAGMA synchronous = ON")
144143
return r
145144
end
@@ -151,13 +150,14 @@ function df2table(df::DataFrame,conn::SqliteDB,name::String)
151150
dfname = name
152151
if dfname == ""
153152
for sym in names(Main)
154-
if is(eval(sym),df)
153+
if string(:(df)) == string(sym)
155154
dfname = string(sym)
156155
end
157156
end
158157
end
159158
#should we loop through column types to specify in create table statement?
160159
internal_query(conn,"create table $dfname ($colnames)")
160+
internal_query(conn,"BEGIN TRANSACTION")
161161
#prepare insert table with parameters for column values
162162
params = chop(repeat("?,",ncols))
163163
stmt, r = internal_query(conn,"insert into $dfname values ($params)",false,false)
@@ -181,6 +181,7 @@ function df2table(df::DataFrame,conn::SqliteDB,name::String)
181181
sqlite3_reset(stmt)
182182
end
183183
sqlite3_finalize(stmt)
184+
internal_query(conn,"COMMIT")
184185
return
185186
end
186187
function droptable(table::String,conn::SqliteDB=sqlitedb)

0 commit comments

Comments
 (0)