Issue with database name with "\"
use a database name with \ it
#server name is someserver123\data
#database name = Comissions
#no user name and password because Trusted_Connection = yes
import pandas as pd
import d6tstack.utils
myfile = "myfile.csv" #absolute file
csv_file = pd.read_csv(my_file, iterator = True, chunksize= 20000, low_memory=False, dtype=str)
for i, chunk in enumerate(csv_file):
d6tstack.utils.pd_to_mssql(chunk , 'mssql+pymssql://someserver123\data/Comissions', 'dbo.mydb', if_exists="append")
will yield error
UserWarning:
.pd_to_mssql()is experimental, if any problems please raise an issue on https://github.com/d6t/d6tstack/issues or make a pull request warnings.warn('.pd_to_mssql()is experimental, if any problems please raise an issue on https://github.com/d6t/d6tstack/issues or make a pull request') Traceback (most recent call last): File "src\pymssql.pyx", line 636, in pymssql.connect File "src_mssql.pyx", line 1957, in _mssql.connect File "src_mssql.pyx", line 677, in _mssql.MSSQLConnection.init _mssql.MSSQLDriverException: Connection to the database failed for an unknown reason.
this error is familiar with pyodbc, to fix this on pyodbc i use urllib and add a param. I dont know how to pull this off with d6stack
Hopefully you solved this by now, but adding r in front of your string like r'mssql+pymssql://someserver123\data/Comissions' might work.