Write to CSV file and export it?

Rom, you’re doing it wrong. You don’t want to write files to disk so that IIS can serve them up. That adds security implications as well as increases complexity. All you really need to do is save the CSV directly to the response stream. Here’s the scenario: User wishes to download csv. User submits a … Read more

Confusion: How does SQLiteOpenHelper onUpgrade() behave? And together with import of an old database backup?

What’s the correct way of handling database upgrades of a live app, so the user doesn’t lose his data? Do you have to check all possible (old) versions in the onUpgrade() method and execute different alter table statements based on that version? By and large, yes. A common approach to this is to do pair-wise … Read more

ES6 export all values from object

I can’t really recommend this solution work-around but it does function. Rather than exporting an object, you use named exports each member. In another file, import the first module’s named exports into an object and export that object as default. Also export all the named exports from the first module using export * from ‘./file1’; … Read more

How to use export with Python on Linux

export is a command that you give directly to the shell (e.g. bash), to tell it to add or modify one of its environment variables. You can’t change your shell’s environment from a child process (such as Python), it’s just not possible. Here’s what’s happening when you try os.system(‘export MY_DATA=”my_export”‘)… /bin/bash process, command `python yourscript.py` … Read more

Export specific rows from a PostgreSQL table as INSERT SQL script

Create a table with the set you want to export and then use the command line utility pg_dump to export to a file: create table export_table as select id, name, city from nyummy.cimory where city = ‘tokyo’ $ pg_dump –table=export_table –data-only –column-inserts my_database > data.sql –column-inserts will dump as insert commands with column names. –data-only … Read more

How to export all collections in MongoDB?

For lazy people, use mongodump, it’s faster: mongodump -d <database_name> -o <directory_backup> And to “restore/import” it (from directory_backup/dump/): mongorestore -d <database_name> <directory_backup> This way, you don’t need to deal with all collections individually. Just specify the database. Note that I would recommend against using mongodump/mongorestore for big data storages. It is very slow and once … Read more