Utility for using mssql-tools BCP command with Django models
Project description
# django-sql-server-bcp
A utility for using mssql-tools BCP command with Django models.
#Usage
Example Django model:
```python
from django.db import models
class StockPrice(models.Model):
id = models.AutoField(primary_key=True)
symbol = models.CharField(max_length=50)
price = models.DecimalField(max_digits=15, decimal_places=4)
timestamp = models.DateTimeField()
```
Example BCP usage with `StockPrice` Model:
```python
from random import radom
rows = []
for i in range(1, row_count):
rows.append(dict(
symbol='GOOG',
price='%.2f' % (100 * random()),
timestamp=str(datetime.datetime.now())
))
bcp = BCP(StockPrice)
bcp.save(rows)
cp.save(rows)
```
#Caveats
- String data cannot contain commas or newlines because bulk data file format is flimsy CSV.
- Untested with long strings, dates, binary data.
A utility for using mssql-tools BCP command with Django models.
#Usage
Example Django model:
```python
from django.db import models
class StockPrice(models.Model):
id = models.AutoField(primary_key=True)
symbol = models.CharField(max_length=50)
price = models.DecimalField(max_digits=15, decimal_places=4)
timestamp = models.DateTimeField()
```
Example BCP usage with `StockPrice` Model:
```python
from random import radom
rows = []
for i in range(1, row_count):
rows.append(dict(
symbol='GOOG',
price='%.2f' % (100 * random()),
timestamp=str(datetime.datetime.now())
))
bcp = BCP(StockPrice)
bcp.save(rows)
cp.save(rows)
```
#Caveats
- String data cannot contain commas or newlines because bulk data file format is flimsy CSV.
- Untested with long strings, dates, binary data.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for django-sql-server-bcp-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 033b0762433f1c875958b1ccd19c0e1d81d8fb1b96206a5999eed8eec5249eb3 |
|
MD5 | 734c057947d602d78c2e824e29758eb2 |
|
BLAKE2b-256 | 3e42ab2c7264017169916aebea4e411a563330f8502b77a5f87238a97c9b9aa3 |