Re: Problem to connect to database only when run "migrate"

2021-06-22 Thread Heron
Thank you Aziz


Regards,
_

Heron
hero...@gmail.com
_


Em ter., 22 de jun. de 2021 às 15:29, Aziz Meknassi 
escreveu:

> Hi Heron,
>
> To make sure you are talking to your database,
> in your project and in your command line, type
>  python manage.py shell
> then import your model
>
> If for example you have prodApp and model Product
> from prodApp.models import Product
> prd = Product.objects.all()
> print(prd)
> Please checkout ORM (
> https://docs.djangoproject.com/en/3.2/topics/db/queries/ )operations, if
> you can talk to the database via ORM and see the data in your database,
> then everything is setup correctly and you need to look into the settings
> etc
>
> I hope this helps
>
> Kind regards
> Aziz Meknassi
>
> On Mon, 21 Jun 2021 at 21:44, Heron  wrote:
>
>> Yes,
>>
>> And its works fine with runserver, check or with apache/wscgi
>>
>> regards,
>> _
>>
>> Heron
>> hero...@gmail.com
>> _
>>
>>
>> Em dom., 20 de jun. de 2021 às 07:31, Luciano Martins 
>> escreveu:
>>
>>>
>>> have you configured mysql database in settings.py?
>>> Em sábado, 19 de junho de 2021 às 09:19:09 UTC-3, her...@gmail.com
>>> escreveu:
>>>
>>>> Hello,
>>>>
>>>> I getting problem to connect to database only when run "migrate". I'm
>>>> able to use on apache/wsgi and runserver, so it's seens that connection to
>>>> database is okay. Dango is running on docker.
>>>>
>>>> Anyone can help me ?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> bash-4.2# python manage.py migrate
>>>> /usr/local/lib/python2.7/site-packages/jwt/utils.py:8:
>>>> CryptographyDeprecationWarning: Python 2 is no longer supported by the
>>>> Python core team. Support for it is now deprecated in cryptography, and
>>>> will be removed in the next release.
>>>>   from cryptography.hazmat.primitives.asymmetric.utils import (
>>>> Traceback (most recent call last):
>>>>   File "manage.py", line 46, in 
>>>> execute_from_command_line(sys.argv)
>>>>   File
>>>> "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>>>> line 364, in execute_from_command_line
>>>> utility.execute()
>>>>   File
>>>> "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>>>> line 356, in execute
>>>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>>>   File
>>>> "/usr/local/lib/python2.7/site-packages/django/core/management/base.py",
>>>> line 283, in run_from_argv
>>>> self.execute(*args, **cmd_options)
>>>>   File
>>>> "/usr/local/lib/python2.7/site-packages/django/core/management/base.py",
>>>> line 327, in execute
>>>> self.check()
>>>>   File
>>>> "/usr/local/lib/python2.7/site-packages/django/core/management/base.py",
>>>> line 359, in check
>>>> include_deployment_checks=include_deployment_checks,
>>>>   File
>>>> "/usr/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
>>>> line 61, in _run_checks
>>>> issues = run_checks(tags=[Tags.database])
>>>>   File
>>>> "/usr/local/lib/python2.7/site-packages/django/core/checks/registry.py",
>>>> line 81, in run_checks
>>>> new_errors = check(app_configs=app_configs)
>>>>   File
>>>> "/usr/local/lib/python2.7/site-packages/django/core/checks/database.py",
>>>> line 10, in check_database_backends
>>>> issues.extend(conn.validation.check(**kwargs))
>>>>   File
>>>> "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/validation.py",
>>>> line 9, in check
>>>> issues.extend(self._check_sql_mode(**kwargs))
>>>>   File
>>>> "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/validation.py",
>>>> line 13, in _check_sql_mode
>>>> with self.connection.cursor() as cursor:
>>>>   File
>>>> "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
>>>> line 254, in cursor
>>>> return self._cursor()
>>>>   File
>>

Re: Problem to connect to database only when run "migrate"

2021-06-22 Thread Aziz Meknassi
Hi Heron,

To make sure you are talking to your database,
in your project and in your command line, type
 python manage.py shell
then import your model

If for example you have prodApp and model Product
from prodApp.models import Product
prd = Product.objects.all()
print(prd)
Please checkout ORM (
https://docs.djangoproject.com/en/3.2/topics/db/queries/ )operations, if
you can talk to the database via ORM and see the data in your database,
then everything is setup correctly and you need to look into the settings
etc

I hope this helps

Kind regards
Aziz Meknassi

On Mon, 21 Jun 2021 at 21:44, Heron  wrote:

> Yes,
>
> And its works fine with runserver, check or with apache/wscgi
>
> regards,
> _
>
> Heron
> hero...@gmail.com
> _
>
>
> Em dom., 20 de jun. de 2021 às 07:31, Luciano Martins 
> escreveu:
>
>>
>> have you configured mysql database in settings.py?
>> Em sábado, 19 de junho de 2021 às 09:19:09 UTC-3, her...@gmail.com
>> escreveu:
>>
>>> Hello,
>>>
>>> I getting problem to connect to database only when run "migrate". I'm
>>> able to use on apache/wsgi and runserver, so it's seens that connection to
>>> database is okay. Dango is running on docker.
>>>
>>> Anyone can help me ?
>>>
>>>
>>>
>>>
>>>
>>> bash-4.2# python manage.py migrate
>>> /usr/local/lib/python2.7/site-packages/jwt/utils.py:8:
>>> CryptographyDeprecationWarning: Python 2 is no longer supported by the
>>> Python core team. Support for it is now deprecated in cryptography, and
>>> will be removed in the next release.
>>>   from cryptography.hazmat.primitives.asymmetric.utils import (
>>> Traceback (most recent call last):
>>>   File "manage.py", line 46, in 
>>> execute_from_command_line(sys.argv)
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>>> line 364, in execute_from_command_line
>>> utility.execute()
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>>> line 356, in execute
>>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/core/management/base.py",
>>> line 283, in run_from_argv
>>> self.execute(*args, **cmd_options)
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/core/management/base.py",
>>> line 327, in execute
>>> self.check()
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/core/management/base.py",
>>> line 359, in check
>>> include_deployment_checks=include_deployment_checks,
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
>>> line 61, in _run_checks
>>> issues = run_checks(tags=[Tags.database])
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/core/checks/registry.py",
>>> line 81, in run_checks
>>> new_errors = check(app_configs=app_configs)
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/core/checks/database.py",
>>> line 10, in check_database_backends
>>> issues.extend(conn.validation.check(**kwargs))
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/validation.py",
>>> line 9, in check
>>> issues.extend(self._check_sql_mode(**kwargs))
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/validation.py",
>>> line 13, in _check_sql_mode
>>> with self.connection.cursor() as cursor:
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
>>> line 254, in cursor
>>> return self._cursor()
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
>>> line 229, in _cursor
>>> self.ensure_connection()
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
>>> line 213, in ensure_connection
>>> self.connect()
>>>   File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line
>>> 94, in __exit__
>>> six.reraise(dj_exc_type, dj_exc_value, traceback)
>>>   File
>>> "/usr/local/lib/python2.7/si

Re: Problem to connect to database only when run "migrate"

2021-06-21 Thread Heron
Yes,

And its works fine with runserver, check or with apache/wscgi

regards,
_

Heron
hero...@gmail.com
_


Em dom., 20 de jun. de 2021 às 07:31, Luciano Martins 
escreveu:

>
> have you configured mysql database in settings.py?
> Em sábado, 19 de junho de 2021 às 09:19:09 UTC-3, her...@gmail.com
> escreveu:
>
>> Hello,
>>
>> I getting problem to connect to database only when run "migrate". I'm
>> able to use on apache/wsgi and runserver, so it's seens that connection to
>> database is okay. Dango is running on docker.
>>
>> Anyone can help me ?
>>
>>
>>
>>
>>
>> bash-4.2# python manage.py migrate
>> /usr/local/lib/python2.7/site-packages/jwt/utils.py:8:
>> CryptographyDeprecationWarning: Python 2 is no longer supported by the
>> Python core team. Support for it is now deprecated in cryptography, and
>> will be removed in the next release.
>>   from cryptography.hazmat.primitives.asymmetric.utils import (
>> Traceback (most recent call last):
>>   File "manage.py", line 46, in 
>> execute_from_command_line(sys.argv)
>>   File
>> "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>> line 364, in execute_from_command_line
>> utility.execute()
>>   File
>> "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>> line 356, in execute
>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>   File
>> "/usr/local/lib/python2.7/site-packages/django/core/management/base.py",
>> line 283, in run_from_argv
>> self.execute(*args, **cmd_options)
>>   File
>> "/usr/local/lib/python2.7/site-packages/django/core/management/base.py",
>> line 327, in execute
>> self.check()
>>   File
>> "/usr/local/lib/python2.7/site-packages/django/core/management/base.py",
>> line 359, in check
>> include_deployment_checks=include_deployment_checks,
>>   File
>> "/usr/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
>> line 61, in _run_checks
>> issues = run_checks(tags=[Tags.database])
>>   File
>> "/usr/local/lib/python2.7/site-packages/django/core/checks/registry.py",
>> line 81, in run_checks
>> new_errors = check(app_configs=app_configs)
>>   File
>> "/usr/local/lib/python2.7/site-packages/django/core/checks/database.py",
>> line 10, in check_database_backends
>> issues.extend(conn.validation.check(**kwargs))
>>   File
>> "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/validation.py",
>> line 9, in check
>> issues.extend(self._check_sql_mode(**kwargs))
>>   File
>> "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/validation.py",
>> line 13, in _check_sql_mode
>> with self.connection.cursor() as cursor:
>>   File
>> "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
>> line 254, in cursor
>> return self._cursor()
>>   File
>> "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
>> line 229, in _cursor
>> self.ensure_connection()
>>   File
>> "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
>> line 213, in ensure_connection
>> self.connect()
>>   File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line
>> 94, in __exit__
>> six.reraise(dj_exc_type, dj_exc_value, traceback)
>>   File
>> "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
>> line 213, in ensure_connection
>> self.connect()
>>   File
>> "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
>> line 189, in connect
>> self.connection = self.get_new_connection(conn_params)
>>   File
>> "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
>> line 274, in get_new_connection
>> conn = Database.connect(**conn_params)
>>   File "/usr/local/lib64/python2.7/site-packages/MySQLdb/__init__.py",
>> line 81, in Connect
>> return Connection(*args, **kwargs)
>>   File "/usr/local/lib64/python2.7/site-packages/MySQLdb/connections.py",
>> line 193, in __init__
>> super(Connection, self).__init__(*args, **kwargs2)
>> django.db.utils.OperationalError: (2003, "Can't connect to MySQL server
>> on '192.168.201.193' (113)")
&

Re: Problem to connect to database only when run "migrate"

2021-06-20 Thread Luciano Martins

have you configured mysql database in settings.py?
Em sábado, 19 de junho de 2021 às 09:19:09 UTC-3, her...@gmail.com escreveu:

> Hello,
>
> I getting problem to connect to database only when run "migrate". I'm able 
> to use on apache/wsgi and runserver, so it's seens that connection to 
> database is okay. Dango is running on docker.
>
> Anyone can help me ?
>
>
>
>
>
> bash-4.2# python manage.py migrate
> /usr/local/lib/python2.7/site-packages/jwt/utils.py:8: 
> CryptographyDeprecationWarning: Python 2 is no longer supported by the 
> Python core team. Support for it is now deprecated in cryptography, and 
> will be removed in the next release.
>   from cryptography.hazmat.primitives.asymmetric.utils import (
> Traceback (most recent call last):
>   File "manage.py", line 46, in 
> execute_from_command_line(sys.argv)
>   File 
> "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", 
> line 364, in execute_from_command_line
> utility.execute()
>   File 
> "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", 
> line 356, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", 
> line 283, in run_from_argv
> self.execute(*args, **cmd_options)
>   File 
> "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", 
> line 327, in execute
> self.check()
>   File 
> "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", 
> line 359, in check
> include_deployment_checks=include_deployment_checks,
>   File 
> "/usr/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
>  
> line 61, in _run_checks
> issues = run_checks(tags=[Tags.database])
>   File 
> "/usr/local/lib/python2.7/site-packages/django/core/checks/registry.py", 
> line 81, in run_checks
> new_errors = check(app_configs=app_configs)
>   File 
> "/usr/local/lib/python2.7/site-packages/django/core/checks/database.py", 
> line 10, in check_database_backends
> issues.extend(conn.validation.check(**kwargs))
>   File 
> "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/validation.py",
>  
> line 9, in check
> issues.extend(self._check_sql_mode(**kwargs))
>   File 
> "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/validation.py",
>  
> line 13, in _check_sql_mode
> with self.connection.cursor() as cursor:
>   File 
> "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py", 
> line 254, in cursor
> return self._cursor()
>   File 
> "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py", 
> line 229, in _cursor
> self.ensure_connection()
>   File 
> "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py", 
> line 213, in ensure_connection
> self.connect()
>   File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line 
> 94, in __exit__
> six.reraise(dj_exc_type, dj_exc_value, traceback)
>   File 
> "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py", 
> line 213, in ensure_connection
> self.connect()
>   File 
> "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py", 
> line 189, in connect
> self.connection = self.get_new_connection(conn_params)
>   File 
> "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", 
> line 274, in get_new_connection
> conn = Database.connect(**conn_params)
>   File "/usr/local/lib64/python2.7/site-packages/MySQLdb/__init__.py", 
> line 81, in Connect
> return Connection(*args, **kwargs)
>   File "/usr/local/lib64/python2.7/site-packages/MySQLdb/connections.py", 
> line 193, in __init__
> super(Connection, self).__init__(*args, **kwargs2)
> django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on 
> '192.168.201.193' (113)")
> bash-4.2# python manage.py check
> /usr/local/lib/python2.7/site-packages/jwt/utils.py:8: 
> CryptographyDeprecationWarning: Python 2 is no longer supported by the 
> Python core team. Support for it is now deprecated in cryptography, and 
> will be removed in the next release.
>   from cryptography.hazmat.primitives.asymmetric.utils import (
>
> 2021-06-18 20:00:05 [DEBUG] [boto:provider:get_credentials:280] 
> [MainThread]
> Using access key provided by client.
>
> 2021-06-18 20:00:05 [DEBUG] [boto:provider:ge

Problem to connect to database only when run "migrate"

2021-06-19 Thread Heron
Hello,

I getting problem to connect to database only when run "migrate". I'm able
to use on apache/wsgi and runserver, so it's seens that connection to
database is okay. Dango is running on docker.

Anyone can help me ?





bash-4.2# python manage.py migrate
/usr/local/lib/python2.7/site-packages/jwt/utils.py:8:
CryptographyDeprecationWarning: Python 2 is no longer supported by the
Python core team. Support for it is now deprecated in cryptography, and
will be removed in the next release.
  from cryptography.hazmat.primitives.asymmetric.utils import (
Traceback (most recent call last):
  File "manage.py", line 46, in 
execute_from_command_line(sys.argv)
  File
"/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py",
line 364, in execute_from_command_line
utility.execute()
  File
"/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py",
line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File
"/usr/local/lib/python2.7/site-packages/django/core/management/base.py",
line 283, in run_from_argv
self.execute(*args, **cmd_options)
  File
"/usr/local/lib/python2.7/site-packages/django/core/management/base.py",
line 327, in execute
self.check()
  File
"/usr/local/lib/python2.7/site-packages/django/core/management/base.py",
line 359, in check
include_deployment_checks=include_deployment_checks,
  File
"/usr/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
line 61, in _run_checks
issues = run_checks(tags=[Tags.database])
  File
"/usr/local/lib/python2.7/site-packages/django/core/checks/registry.py",
line 81, in run_checks
new_errors = check(app_configs=app_configs)
  File
"/usr/local/lib/python2.7/site-packages/django/core/checks/database.py",
line 10, in check_database_backends
issues.extend(conn.validation.check(**kwargs))
  File
"/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/validation.py",
line 9, in check
issues.extend(self._check_sql_mode(**kwargs))
  File
"/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/validation.py",
line 13, in _check_sql_mode
with self.connection.cursor() as cursor:
  File
"/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
line 254, in cursor
return self._cursor()
  File
"/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
line 229, in _cursor
self.ensure_connection()
  File
"/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
line 213, in ensure_connection
self.connect()
  File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line
94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
  File
"/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
line 213, in ensure_connection
self.connect()
  File
"/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
line 189, in connect
self.connection = self.get_new_connection(conn_params)
  File
"/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
line 274, in get_new_connection
conn = Database.connect(**conn_params)
  File "/usr/local/lib64/python2.7/site-packages/MySQLdb/__init__.py", line
81, in Connect
return Connection(*args, **kwargs)
  File "/usr/local/lib64/python2.7/site-packages/MySQLdb/connections.py",
line 193, in __init__
super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on
'192.168.201.193' (113)")
bash-4.2# python manage.py check
/usr/local/lib/python2.7/site-packages/jwt/utils.py:8:
CryptographyDeprecationWarning: Python 2 is no longer supported by the
Python core team. Support for it is now deprecated in cryptography, and
will be removed in the next release.
  from cryptography.hazmat.primitives.asymmetric.utils import (

2021-06-18 20:00:05 [DEBUG] [boto:provider:get_credentials:280] [MainThread]
Using access key provided by client.

2021-06-18 20:00:05 [DEBUG] [boto:provider:get_credentials:307] [MainThread]
Using secret key provided by client.

2021-06-18 20:00:05 [DEBUG] [boto:provider:get_credentials:280] [MainThread]
Using access key provided by client.

2021-06-18 20:00:05 [DEBUG] [boto:provider:get_credentials:307] [MainThread]
Using secret key provided by client.
System check identified no issues (0 silenced).

Regards,
_

Heron
hero...@gmail.com
_

>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFjM0T0nxQCg-j17yhpKkcMwWd_ECbURWctKgawzXP_W9TPG0Q%40mail.gmail.com.