-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No default encoding (2.0.0a1) #162
Comments
@rcucui,
Your link labeled "
|
@RossRogers I went one line too low into the The original traceback raises an exception at line 394:
|
I guess we can change like: diff --git a/django_pyodbc/base.py b/django_pyodbc/base.py
index dab5399..07357de 100644
--- a/django_pyodbc/base.py
+++ b/django_pyodbc/base.py
@@ -392,7 +392,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
self.driver_supports_utf8 = (self.drv_name == 'SQLSRV32.DLL'
or ms_sqlncli.match(self.drv_name))
- return CursorWrapper(cursor, self.driver_supports_utf8, self.encoding, self)
+ return CursorWrapper(cursor, self.driver_supports_utf8, getattr(self, 'encoding', 'utf-8'), self)
def _execute_foreach(self, sql, table_names=None):
cursor = self.cursor() Anyways, I'm not sure how functional the library is without the database configuration. |
I kept getting the error
AttributeError: 'DatabaseWrapper' object has no attribute 'encoding'
and it turns out that encoding is only set by default in this block of base.py if there is anOPTIONS
key who's value is a dictionary with least one key.Workaround: add an
OPTIONS
key to your config that has a populated dictionaryPossible solutions:
and also update the README.rst to reflect that encoding isn't only set to 'utf-8' by default when
OPTIONS
is specifiedCursorWrapper's init function is ready to handle None/empty string values, so I'm not sure which solution works better behind the goals of the project.
The text was updated successfully, but these errors were encountered: