nateraw commited on
Commit
8842b31
1 Parent(s): cd7c3bd

Create new file

Browse files
Files changed (1) hide show
  1. snowflaketest.py +85 -0
snowflaketest.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """A dataset script that will hit Snowflake DB and return the results."""
2
+
3
+ try:
4
+ import snowflake.connector as connector
5
+ except:
6
+ ModuleNotFoundError("Please install snowflake connector: pip install snowflake-connector-python")
7
+
8
+ import datasets
9
+
10
+
11
+ # TODO: Add BibTeX citation
12
+ # Find for instance the citation on arxiv or on the dataset repo/website
13
+ _CITATION = """\
14
+ @InProceedings{huggingface:dataset,
15
+ title = {A great new dataset},
16
+ author={huggingface, Inc.
17
+ },
18
+ year={2020}
19
+ }
20
+ """
21
+
22
+ # TODO: Add description of the dataset here
23
+ # You can copy an official description
24
+ _DESCRIPTION = """\
25
+ This new dataset is designed to solve this great NLP task and is crafted with a lot of care.
26
+ """
27
+
28
+ # TODO: Add a link to an official homepage for the dataset here
29
+ _HOMEPAGE = ""
30
+
31
+ # TODO: Add the licence for the dataset here if you can find it
32
+ _LICENSE = ""
33
+
34
+
35
+ # TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
36
+ class NewDataset(datasets.GeneratorBasedBuilder):
37
+ """TODO: Short description of my dataset."""
38
+
39
+ def _info(self):
40
+ return datasets.DatasetInfo(
41
+ description=_DESCRIPTION,
42
+ features=datasets.Features(
43
+ {
44
+ "text": datasets.Value("string"),
45
+ "label": datasets.ClassLabel(names=['sadness', 'joy', 'love', 'anger', 'fear', 'surprise']),
46
+ }
47
+ ),
48
+ homepage=_HOMEPAGE,
49
+ license=_LICENSE,
50
+ citation=_CITATION,
51
+ )
52
+
53
+ def _split_generators(self, dl_manager):
54
+
55
+ conn = connector.connect(
56
+ user='rajiv',
57
+ password='Password123!',
58
+ account='VUA92284',
59
+ warehouse='RAJIV',
60
+ database='HUGGINGFACE',
61
+ schema='PUBLIC',
62
+ role = 'RAJIV'
63
+ )
64
+
65
+ curr = conn.cursor()
66
+
67
+
68
+ sql = "select * from EMOTION"
69
+ curr = curr.execute(sql)
70
+
71
+ return [
72
+ datasets.SplitGenerator(
73
+ name=datasets.Split.TRAIN,
74
+ gen_kwargs={"cursor": curr},
75
+ )
76
+ ]
77
+
78
+ def _generate_examples(self, cursor):
79
+ for i, ex in enumerate(cursor):
80
+ yield str(i), {
81
+ "text": ex[0],
82
+ "label": ex[1],
83
+ }
84
+ # Probably not necessary but just in case...we close the connection which we can find within the cursor object
85
+ cursor.connection.close()