I've an web page which reads the data from (server side) database and write into csv file, but as per requirement I need to write the file in client side and asked user to save the file in their local machine with popup window to save the location (client side), how do we do this using python.

Request: PLease do not suggest the third party libs.

From what I understand in your post, you can make a variable of the database when you read it. For example,

database_file = #your database file and method of IO
save_file = open('blahblahcsv','w')

save_file.write(str(database_file))
save_file.close()

If your database file has more than one line, you could also use the for statement. For example:

for line in database_file:
    save_file.write(line)
    save_file.close()

Remember to insert the .close() statement, or your written data will not appear in the csv file.

I've an web page which reads the data from (server side) database and write into csv file, but as per requirement I need to write the file in client side and asked user to save the file in their local machine with popup window to save the location (client side), how do we do this using python.

For the popup window, you'll have to use Tkinter (built in with Python).
On the writing side:
You can do this too:

#Save your database file in a text file

database_file = open('yoursavedfile.txt','r')
# then use the save_file method that I showed you in the previous post

3eOjUn has close statement inside the loop, please unindent it out of the loop.

Probably I might not clear my question, i.e. I'll get the data from the database to the client side as a Dictionary. When the user requested as save to a file, then loop the dictionary and write to a csv file and asked user to save that file into his local machine..PLease advice

Let's see if you I have this correct. You have a web page with a server-side Python script which extacts data from a database and is supposed to pass it on to the client. On the client side, you need to have a dialog box come up and request a location to save the data file to, then once the request is complete, it should save the file to the location given. Is this correct?

The problem here is that the Python script is running server side, not client side, and there really isn't a way to get a Python script running client side that I can think of. I would expect you'd need to use at least some small amount of JavaScript or some similar client-side scripting in order to do what you want.

Thanks for replying..
I've client side scripting (HTML code to set inputs and expect results on the same page and as well in file <My requirement> ) and client side scripting (fetching data through SQLs based on the inputs received from client, and return the result as Dictionary to client side) In this case I can show the data easily on screen but file saving in local machine is tough for me.
I think I cleared my request... Please advice

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.