semvec/pypi-packages huggingface dataset:
keboola.csvwriter 1.0.1
ElasticDictWriter module based on Python csv package ensuring consistent header in the final CSV.
Requires Python: >=3.7

# CSV ElasticDictWriter


DictWriter, built on top of csv.DictWriter, that supports automatic extension of headers according to what data it receives.
The result file always has a complete header (as defined by fieldnames) or it is extended if some new columns
 are introduced in the data. It always produces a valid CSV (missing columns are filled with blanks).
 It uses a series of cached writers / files that are merged into a single one with final set of columns on close()


## Installation 
 
The package may be installed via PIP:
 
```
pip install keboola.csvwriter
```



**NOTE:** If not using "with" statement, close() method must be called at the end of processing to get the result.

**NOTE:** Does not keep the order of rows added - the rows containing additional headers always come first:

### Example:

```python
from keboola.csvwriter import ElasticDictWriter
file = '/test/test.csv'
wr = ElasticDictWriter(file, ["a", "b" , "c"])
wr.writeheader()
wr.writerow({"a":1,"b":2})
wr.writerow({"b":2, "d":4})
wr.close()

```

leads to CSV with following content:
   
|a  |b  |c  |d  |
|---|---|---|---|
|   |2  |   |4  |
|1  | 2 |   |   |

May be also used with `with` statement to automatically close once finished:

```python
from keboola.csvwriter import ElasticDictWriter
file = '/test/test.csv'
with ElasticDictWriter(file, ["a", "b" , "c"]) as wr:
    wr.writeheader()
    wr.writerow({"a":1,"b":2})
    wr.writerow({"b":2, "d":4})

# get final headers
final_header = wr.fieldnames
```

**NOTE:** The final column list is stored in `fieldnames` property:

```python
columns = writer.fieldnames
```
py3db 0.0.19
connect to database
Requires Python: >=3.6

# database操作(支持 mysql mongodb elasticSearch sqlite3)
## How to use
### mysql

#### connect

```python
mysql = MySql("localhost", "root", "123456", "test")
```

#### insert

```python
# insert into test values(1,'Mike','male')
mysql.insert_one("test", columns_list=[1, "Mike", "male"])

# insert into test(id,name,gender) values(1,'Mike','male')
mysql.insert_one("test", columns_dict={"id": 1, "name": "Mike", "gender": "male"})
```

#### update

```python
 #  update test set id=12 where id>12
 mysql.update('test', {'id': 12}, {"id": {
        "compare": ">",
        "value": 12
    }})

#  update test  set id=12 where name='mike'
 mysql.update('test', {'id': 12}, {"name": "mike"})   
```

#### select

```python
#  select * from test;
mysql.select("test")

#  select name,score,age from test;
mysql.select("test",["name","score","age"])

#  select name,score,age from test where name='XiaoMing';
 mysql.select("test",["name","score","age"],{'name':'XiaoMing'})
```

#### delete

````python
#  delete from test;
mysql.delete("test")

#  delete from test where name='LiBai'
mysql.delete("test",{"name":"LiBai"})
````



### mongodb

### elasticSearch
### sqlite3

#### connect

```python
sqlite = Sqlite("localhost", "root", "123456", "test")
```

#### insert

```python
# insert into test values(1,'Mike','male')
sqlite.insert_one("test", columns_list=[1, "Mike", "male"])

# insert into test(id,name,gender) values(1,'Mike','male')
sqlite.insert_one("test", columns_dict={"id": 1, "name": "Mike", "gender": "male"})
```

#### update

```python
 #  update test set id=12 where id>12
 sqlite.update('test', {'id': 12}, {"id": {
        "compare": ">",
        "value": 12
    }})

#  update test  set id=12 where name='mike'
 sqlite.update('test', {'id': 12}, {"name": "mike"})   
```

#### select

```python
#  select * from test;
sqlite.select("test")

#  select name,score,age from test;
sqlite.select("test",["name","score","age"])

#  select name,score,age from test where name='XiaoMing';
 sqlite.select("test",["name","score","age"],{'name':'XiaoMing'})
```

#### delete

````python
#  delete from test;
sqlite.delete("test")

#  delete from test where name='LiBai'
sqlite.delete("test",{"name":"LiBai"})
````