DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: NANY 2018 - 6 Command line Database utilities  (Read 20,678 times)

chesterw

  • Member
  • Joined in 2011
  • **
  • Posts: 10
    • Participated in NANY Challenge Three Times
NANY 2018 - 6 Command line Database utilities
« on: September 20, 2017, 12:12 PM »
I have noticed that there often is a need to dump database information into a CSV file.  Users then can use
Excel or a similar program to manipulate the data.  These utilities are easy to use, flexible, and fast.
There are 2 utilities for Oracle, 2 for Microsoft SQL, and 2 for SQLite.  They convert a table or SQL into a CSV file.

Oracle:
  OracleTableToCSV.exe      Converts an entire table into a CSV file.
  OracleQueryToCSV.exe      Converts an SQL query result into a CSV file.

Microsoft:
  MSTableToCSV.exe          Converts an entire table into a CSV file.
  MSQueryToCSV.exe          Converts an SQL query result into a CSV file.

SQLite:
  SqliteTableToCSV.exe      Converts an entire table into a CSV file.
  SqliteQueryToCSV.exe      Converts an SQL query result into a CSV file.

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 9,827
    • Participated in NANY Challenge Eight Times
    • Cody Award
Re: NANY 2018 - 6 Command line Database utilities
« Reply #1 on: September 21, 2017, 01:54 AM »
I took the liberty to download the file and submit it to Jotti's malware scanner. 1 AV returned a result, which is likely a false-positive.

https://virusscan.jotti.org/en-US/filescanjob/2q535hrt21

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,649
    • Participated in NANY Challenge Eleven Times
    • Coding Snacks
    • Linux User
    • Hardware Hacker
Re: NANY 2018 - 6 Command line Database utilities
« Reply #2 on: September 21, 2017, 06:36 AM »
@chesterw: It would be nice to hear how you made this (start by using the NANY template in your post), any future plans you have with this, and as a developer I'm interested in the technology stuff used as well.
/Ton
Ath's software collection, Quote: "A problem well stated is a problem half-solved." (Charles Kettering)

x16wda

  • what am I doing in this handbasket?
  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 888
    • Participated in NANY Challenge Once
Re: NANY 2018 - 6 Command line Database utilities
« Reply #3 on: September 21, 2017, 10:45 AM »
I took the liberty to download the file and submit it to Jotti's malware scanner. 1 AV returned a result, which is likely a false-positive.

Scanners like to mark any exe that has been compressed (like with UPX) as potential malware. The scanners are probably ticked off that they would have to go through an unpacking process to scan the payload properly, so being the lazy curs that they are, they opt to just mark it as bad stuff without really checking.

That said, I am curious why people still pack their exe's these days. Disk space isn't nearly the problem it was years ago, when storage topped out in the low gbs, and bandwidth savings can't possibly be a real concern unless you're going to get millions of downloads.
vi vi vi - editor of the beast

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: NANY 2018 - 6 Command line Database utilities
« Reply #4 on: September 22, 2017, 12:29 AM »
What x16wda said.
These days it seems packing your exe is just asking for headaches with antivirus tools.

chesterw

  • Member
  • Joined in 2011
  • **
  • Posts: 10
    • Participated in NANY Challenge Three Times
Re: NANY 2018 - 6 Command line Database utilities
« Reply #5 on: October 24, 2017, 12:18 PM »
Because Delphi is such a popular tool throughout the world, those who write viruses often use Delphi.  Normal library routines in Delphi produce strings of characters in most Delphi programs.  In error, some antivirus heuristics look for those strings of characters and automatically label (falsely) a program as a virus.  So if I submit a program in Delphi, it pretty much is guaranteed to be falsely labeled as a virus by some antivirus program.  Packers like UPX compress the final EXE significantly, which speeds up file transfers, and has the added benefit of avoiding the false positives of some antivirus software.  But then, as pointed out above, they complain that you used UPX to pack the EXE.  I can't win...

Delphi is quite versatile in its database capabilities.  The 6 programs here are really just 2 programs, with slight changes for 3 different databases.  The trick used in the 3 "dump out a table" programs was to discover 3 different ways to get the list of columns.  Every database does it differently.  Once I had the list of column names, and put them at the top of the CSV file, I did a "SELECT * FROM tablename" and wrapped each field with double-quotes and commas, to make a "safe" CSV file, as a field can contain commas.

The other 3 programs for getting the result of a query have the user give me the column names, and a (hopefully pre-tested) query that matches those column names.  Using a similar process as above, I create the CSV file.

The real versatility is using the batch/CMD files to do the routine stuff like passwords, and allow the flexibility of dumping different tables or running a set of custom SQL files.  Enjoy!

pencoe

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 21
Re: NANY 2018 - 6 Command line Database utilities
« Reply #6 on: January 12, 2018, 09:12 AM »
In several years coding in Delphi i had never any complaint about an AV and a Delphi exe, but several false positives with UPX... so i'm with mouser on this one.

Tuxman

  • OMG not him again!
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 2,522
    • Participated in NANY Challenge Seven Times
Re: NANY 2018 - 6 Command line Database utilities
« Reply #7 on: January 12, 2018, 10:29 AM »
I honestly wish more people would come back to Delphi (or Free Pascal, whatever floats your boat) so I can have more reasons to use Delphi for new projects because of a sane ecosystem. As it stands, every additional Delphi Unit that does not come from Embarcadero (or whatever their current name is) is pretty much left to rot. :(

(But Delphi sure does have a nice "standard" library.)
I bet when Cheetahs race and one of them cheats, the other one goes "Man, you're such a Cheetah!" and they laugh & eat a zebra or whatever.

chesterw

  • Member
  • Joined in 2011
  • **
  • Posts: 10
    • Participated in NANY Challenge Three Times
Re: NANY 2018 - 6 Command line Database utilities
« Reply #8 on: July 03, 2018, 03:15 PM »
07/02/2018 - In the 3 QueryToCSV files:
  Corrected a bug that added a blank column to the output file.
  Enhanced error messages.
  Added an N parameter: Output file has a header unless there is this parameter.

Original address: https://www.donationcoder.com/forum/index.php?topic=44374.0