Unable to FTP an sqlite file, even tho it's closed.

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Contact:

Unable to FTP an sqlite file, even tho it's closed.

Post by paulsr » Wed Aug 14, 2013 10:44 am

Greetings:

I have an app running in LC 6.1.1(rc2) on XP which seems to be unable to copy an sqlite database which has been used in the app, even tho it has been closed.

The following code is a snippet I've been using for testing

Code: Select all

revCloseDatabase gDBid --closes newsapp.sqlite
   
put "binfile:" & g_sfp_docs & "/airnews/sqlite/test.sqlite" into tTestDB  
put g_ftp_sqlite & "test.copy" into g_ftp_sqlulpath

--copies test.sqlite to test.copy on server
put url tTestDB into url g_ftp_sqlulpath 
   
put "binfile:" & g_sfp_docs & "/airnews/sqlite/newsapp.sqlite" into tRealDB   
put g_ftp_sqlite & "newsapp.copy" into g_ftp_sqlulpath

--creates empty file newsapp.copy on server
put url tRealDB into url g_ftp_sqlulpath 

The var g_sfp_docs is my local /Documents directory.

The var g_ftp_sqlulpath contains all the ftp info, my username, password, path, etc., and must be correct, because...

The first test, copying a file called test.sqlite to the server works just fine.

The second test, an attempt to copy newsapp.sqlite fails. It logs into the correct path and creates an empty file, but does not upload.

newsapp.sqlite _was_ open in the app, but the revCloseDatabase does close it. I've tried to access it after the close, and correctly get an error.

Can anyone plz explain to me how to FTP a database that has been used but is now closed... Or, can you see an error in my code?

Many thanks...

--paul

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Unable to FTP an sqlite file, even tho it's closed.

Post by Dixie » Wed Aug 14, 2013 11:48 am

Paul...

An example of sending a file to the public_html folder on your server...

Code: Select all

constant FTPHOST = "ftp.someserver.com"
constant FTPUSER = "someuser"
constant FTPPASS = "987654321"

on mouseUp
    # Start by getting the file to upload
    local tFileForUpload, tFileName
    answer file "Select a file to upload"
    put it into tFileForUpload
    
    # Get the name of the file for upload
    set the itemdel to "/"
    put the last item of tFileForUpload into tFileName
    put empty into field 1
    
    # Connect the start the upload
    local tDestination
    put "ftp://" & FTPUSER & ":" & FTPPASS & "@" & FTPHOST & "/public_html/" & tFileName into tDestination
    libURLSetStatusCallback "uploadProgress", the long ID of me
    libURLftpUploadFile tFileForUpload, tDestination, "uploadComplete"
end mouseUp

on uploadComplete pURL, pStatus
    put "Status Update:" && pStatus && return after field 1
end uploadComplete

on uploadProgress pURL, pStatus
    put "Status Update:" && pStatus && return before field 1
end uploadProgress

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Contact:

Re: Unable to FTP an sqlite file, even tho it's closed.

Post by paulsr » Wed Aug 14, 2013 12:01 pm

Thanks Dixie,

I did try using libURLftpUploadFile but it didn't make any difference.

If my code is wrong, which I'm happy to accept, then why does the first upload work? i.e. the file that has not been opened by my code.

--paul

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Unable to FTP an sqlite file, even tho it's closed.

Post by Simon » Mon Aug 19, 2013 12:52 am

Hi Paul,
Have you proved that this has to do with you opening the DB?
What happens if you don't open either of them does it work? (you didn't mention this)

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Contact:

Re: Unable to FTP an sqlite file, even tho it's closed.

Post by paulsr » Mon Aug 19, 2013 8:00 am

Simon wrote:Hi Paul,
Have you proved that this has to do with you opening the DB?
What happens if you don't open either of them does it work? (you didn't mention this)
Simon
Yes Simon, it is related to opening the DB.

I think tho I am somehow managing to open the same DB more than once, but only closing it one time. So, it is in fact open and can not be copied.

I discovered with my test code I could not even make a copy on my own PC, so it had nothing to do with FTP.

Clearly I have a bug, but I'm not yet sure where!

--paul

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Unable to FTP an sqlite file, even tho it's closed.

Post by Simon » Mon Aug 19, 2013 8:14 am

Have you used revOpenDatabases()

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Contact:

Re: Unable to FTP an sqlite file, even tho it's closed.

Post by paulsr » Mon Aug 19, 2013 9:38 am

Simon wrote:Have you used revOpenDatabases()

Simon
Yes, but I think it's getting executed more than once. Am in bug-hunting mode :-)

--paul

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Unable to FTP an sqlite file, even tho it's closed.

Post by Simon » Mon Aug 19, 2013 9:51 am

Note the "s"
revOpenDatabases()
Will tell you if any are still open.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

paulsr
Posts: 222
Joined: Thu Jul 19, 2012 9:47 am
Contact:

Re: Unable to FTP an sqlite file, even tho it's closed.

Post by paulsr » Mon Aug 19, 2013 11:04 am

Oh! Sorry. I thought the 's' was a typo!

Useful. Thanks,

--paul

Post Reply