Seite 2 von 3

Verfasst: Sonntag 8. November 2009, 17:16
von kostonstyle
Habe nun MySQL installiert und die Ausgabe erhalten:

Code: Alles auswählen

running install
running bdist_egg
running egg_info
writing MySQL_python.egg-info/PKG-INFO
writing top-level names to MySQL_python.egg-info/top_level.txt
writing dependency_links to MySQL_python.egg-info/dependency_links.txt
reading manifest file 'MySQL_python.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'MySQL_python.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.6-universal/egg
running install_lib
running build_py
creating build
creating build/lib.macosx-10.6-universal-2.6
copying _mysql_exceptions.py -> build/lib.macosx-10.6-universal-2.6
creating build/lib.macosx-10.6-universal-2.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb
creating build/lib.macosx-10.6-universal-2.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.6-universal-2.6
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -Dversion_info=(1,2,3,'gamma',1) -D__version__=1.2.3c1 -I/usr/local/mysql/include -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.6-universal-2.6/_mysql.o -g -Os -arch x86_64 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL
unable to execute gcc-4.2: No such file or directory
error: command 'gcc-4.2' failed with exit status 1
sieht doch gut aus, würde ich mal meinen.
Nun wie kann ich MySQL modul importieren?

Verfasst: Sonntag 8. November 2009, 17:23
von derdon

Code: Alles auswählen

unable to execute gcc-4.2: No such file or directory
error: command 'gcc-4.2' failed with exit status 1 
sieht doch gut aus, würde ich mal meinen.
:lol:

Verfasst: Sonntag 8. November 2009, 17:40
von kostonstyle
ja, aber nach dieser Anleitung ist es die Fehlermeldung normal
http://www.icoost.com/programmiersprach ... tallieren/

Verfasst: Sonntag 8. November 2009, 17:45
von kostonstyle

Code: Alles auswählen

>>> import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "MySQLdb/__init__.py", line 19, in <module>
    import _mysql
ImportError: No module named _mysql
die installation ist leider misslungen.

Verfasst: Sonntag 8. November 2009, 18:52
von nemomuk
Nein ist es nicht, du hast anscheinend kein gcc installiert! "unable to execute gcc-4.2: No such file or directory"

Verfasst: Montag 9. November 2009, 13:01
von kostonstyle
genau, ich musste xcode installieren und nun funktioniert es perfekt. vielen vielen dank leute....

Verfasst: Mittwoch 11. November 2009, 20:00
von kostonstyle
nun ist mysql server installiert, der nächste schritt ist, was muss ich der django settings.py hinschreiben.
DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = '' # Or path to database file if using sqlite3.
DATABASE_USER = 'root' # Not used with sqlite3.
DATABASE_PASSWORD = 'xxxxxxxx' # Not used with sqlite3.
DATABASE_HOST = '/var/run/mysql' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
Bei name was muss ich hineinschreiben. Hinweis, habe einen Mac. :-)

Verfasst: Mittwoch 11. November 2009, 20:04
von ms4py
Du musst in MySQL eine Datenbank erstellen und diesen Namen dann angeben. Am besten legst du dann auch einen extra Benutzer für diese DB an und verwendest diesen. Mit dem "root" sollte man nie arbeiten.

Außerdem ist dein Host falsch. Host ist der Name unter dem ein Server im Netzwerk erreichbar ist, und nicht (wie bei dir) der Pfad zur Executable. Bei einem lokalen Server (wie bei dir) musst du nichts angeben (bzw. ``localhost``).

Verfasst: Samstag 14. November 2009, 20:19
von kostonstyle
erhalte jetzt die Fehlermeldung

Code: Alles auswählen

Validating models...
Unhandled exception in thread started by <function inner_run at 0x1007b0668>
Traceback (most recent call last):
  File "/Library/Python/2.6/site-packages/django/core/management/commands/runserver.py", line 48, in inner_run
    self.validate(display_num_errors=True)
  File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 249, in validate
    num_errors = get_validation_errors(s, app)
  File "/Library/Python/2.6/site-packages/django/core/management/validation.py", line 67, in get_validation_errors
    connection.validation.validate_field(e, opts, f)
  File "/Library/Python/2.6/site-packages/django/db/backends/mysql/validation.py", line 15, in validate_field
    db_version = connection.get_server_version()
  File "/Library/Python/2.6/site-packages/django/db/backends/mysql/base.py", line 297, in get_server_version
    self.cursor()
  File "/Library/Python/2.6/site-packages/django/db/backends/__init__.py", line 81, in cursor
    cursor = self._cursor()
  File "/Library/Python/2.6/site-packages/django/db/backends/mysql/base.py", line 281, in _cursor
    self.connection = Database.connect(**kwargs)
  File "/Library/Python/2.6/site-packages/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg/MySQLdb/__init__.py", line 81, in Connect
    
  File "/Library/Python/2.6/site-packages/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg/MySQLdb/connections.py", line 188, in __init__
_mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysql' (2)")
was mache ich den falsch

Code: Alles auswählen

DATABASE_ENGINE = 'mysql'           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'web'             # Or path to database file if using sqlite3.
DATABASE_USER = 'webdev'             # Not used with sqlite3.
DATABASE_PASSWORD = 'xxxxxx'         # Not used with sqlite3.
DATABASE_HOST = 'localhost'             # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
habe die Verbindung mit python getestet und klappt

Code: Alles auswählen

import MySQLdb
import sys

try:
    conn = MySQLdb.connect (host = "localhost",
                        user = "webdev",
                        passwd = "xxxxxx",
                        db = "web")
    cursor = conn.cursor()
    cursor.execute ("""SELECT id, data FROM example""")
    row = cursor.fetchall()
    for r in row:
        print(r)
    cursor.close()
    conn.close()
except MySQLdb.Error, e:
    print "Error %d: %s" % (e.args[0], e.args[1])
    sys.exit(1)

    

Verfasst: Samstag 14. November 2009, 20:37
von Leonidas

Code: Alles auswählen

DATABASE_HOST = 'localhost'             # Set to empty string for localhost. Not used with sqlite3.

Verfasst: Samstag 14. November 2009, 20:55
von kostonstyle
DATABASE_HOST = ' ' # Set to empty string for localhost. Not used with sqlite3.
habe jetzt so geändert und erhalte immer noch derselbe Fehlermeldung.

Verfasst: Sonntag 15. November 2009, 12:39
von ms4py
Scheint ein Konfigurationsproblem von deinem MySQL-Server zu sein. Such mal nach der Fehlermeldung bei Google, da gibt es genug Hilfestellungen!

Verfasst: Sonntag 15. November 2009, 13:55
von kostonstyle
mit der konfiguration sollte doch alles in Ordnung sein, weil die Verbindung zwischen python und mysql funktioniert ja, ausser django framework. habe im net schon gesucht, aber leider nichts gefunden.

Verfasst: Sonntag 15. November 2009, 14:04
von kostonstyle
hier noch einen ansicht von server
Bild
es stimmt mit dem socket irgendetwas nicht. in django settings.py

Code: Alles auswählen

DATABASE_ENGINE = 'mysql'           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'example'             # Or path to database file if using sqlite3.
DATABASE_USER = 'webdev'             # Not used with sqlite3.
DATABASE_PASSWORD = 'xxxxxx'         # Not used with sqlite3.
DATABASE_HOST = '/tmp/mysql.sock'             # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.

Verfasst: Sonntag 15. November 2009, 15:15
von apollo13
setz es auf 127.0.0.1; localhost heißt für mysql, dass er sockets verwenden soll, das für die entwicklung aber zumeist herzlichst egal ist würd ich tcp verbindungen nehmen, sind zumeist weniger nervenaufreibend ;()

Verfasst: Sonntag 15. November 2009, 15:50
von kostonstyle
trotz das setzen von 127.0.0.1 erhalte ich immer noch die Fehlermeldung

Verfasst: Sonntag 15. November 2009, 18:10
von ms4py
Ist doch ganz klar was falsch konfiguriert!
Dein Socket ist unter /tmp/mysql.sock und laut Fehler wird unter /var/run/mysql nach dem Socket gesucht...
Was steht denn in deiner my.cnf?

Verfasst: Sonntag 15. November 2009, 19:49
von kostonstyle
wie finde ich dieser my.cnf datei?

Verfasst: Sonntag 15. November 2009, 21:10
von ms4py
/etc/mysql vermutlich

Edit: halt unter Linux, du hast Mac oder? Ist aber vermutlich das selbe.

Verfasst: Montag 16. November 2009, 10:05
von kostonstyle
genau habe ein mac(unix). Muss ich im Verzeichnis Mysql suchen und wie heisst das File genau?