-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinserter.py
36 lines (25 loc) · 840 Bytes
/
inserter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import json
import psycopg2
import os
dumpJsonTableName = "zooplajsondump"
# Me am SMART?
def insertJsonDumpIntoPostgreSQL (jsonString):
sqlCommandString = "INSERT INTO " + dumpJsonTableName + " VALUES ( default," + json.dumps(jsonString) + ")"
connectionHandler(sqlCommandString)
def cleanDumpPostgreSQL() :
return None
def connectionHandler(sqlCommandString):
con = None
try:
con = psycopg2.connect(host='localhost',database='zooplatest', user='externalapi', password='test')
cur = con.cursor()
cur.execute(sqlCommandString)
except:
print(psycopg2.DatabaseError)
sys.exit(1)
finally:
if con:
con.close()
list(map(print,os.sys.argv[1:]))
#sqlCommandString = insertDumpIntoPostgreSQL(jsonString)
#connectionHandler(sqlCommandString)