0

I am generating a CSV file using pandas, I need to create file based on the path stored in file.

Below is my code:

HA_file_path = ''' select CONFIG_VALUE from CONFIGURATIONS where CONFIG_NAME = 'HA''''

I am getting syntax error here, not sure how to get value with single quote from table.

Also i need to attach file name with current date time.

A.L
  • 10,259
  • 10
  • 67
  • 98
digital
  • 3
  • 1
  • I'm not sure if I understand correctly, but is the column name `'HA'` including the single quotes? – juanpethes Jul 13 '23 at 12:02
  • yes .'HA' is in single quote and i a getting error over there – digital Jul 13 '23 at 13:26
  • I am not sure on the standard with single and double quotes and escapation of characters. Try something like `"'HA'"`, I don't know... Maybe this will help? -> https://stackoverflow.com/questions/2901453/sql-standard-to-escape-column-names – juanpethes Jul 13 '23 at 13:32

2 Answers2

1
import os
os.get_cwd()

returns current directory

from datetime import datetime
datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")

returns current time & date

you can try concatenating this strings into your file name

Niqua
  • 386
  • 2
  • 15
0

Try stripping out the single and double quotes from the string variable that holds the file name.strip quotes from strings

betacrash
  • 59
  • 7