㈠ python3如何根據csv文件的列的內容,自動建資料庫表
我這里選「Online Transaction Processing(OLTP)」,自己的伺服器,應該夠用了,按「Next」繼續
是否啟用TCP/IP連接,設定埠,如果不啟用,就只能在自己的機器上訪問mysql數 據庫了,我這里啟用,把前面的勾打上,Port Number:3306,在這個頁面上,您還可以選擇「啟用標准模式」(Enable Strict Mode),這樣MySQL就不會允許細小的語法錯誤。如果您還是個新手,我建議您取消標准模式以減少麻煩。但熟悉MySQL以後,盡量使用標准模式,因 為它可以降低有害數據進入資料庫的可能性。按「Next」繼續
望採納
㈡ python 創建資料庫 出錯。
你給資料庫起的名字也太奇怪了,怎麼全是數字?給點字母好不好,或者用引號包起來:
CREATE DATABASE 「3333333333」
sql_name1=raw_input('name=')
sss="""DROPDATABASEIFEXISTS'%s';CREATEDATABASE'%s';"""%(sql_name1,sql_name1)
printsss
cursor1.execute("""DROPDATABASEIFEXISTS'%s';CREATEDATABASE'%s';"""%(sql_name1,sql_name1))
cursor1.execute(sss)
cursor1.close();
㈢ python3.6下如何用Django1.9創建資料庫報錯
錯誤描述
python==3.5
django==1.7
django創建項目時報錯如下:
Traceback (most recent call last):
File "/root/envs/django-test/bin/django-admin", line 11, in <mole>
sys.exit(execute_from_command_line())
File "/root/envs/django-test/lib/python3.5/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/root/envs/django-test/lib/python3.5/site-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/root/envs/django-test/lib/python3.5/site-packages/django/__init__.py", line 18, in setup
from django.utils.log import configure_logging
File "/root/envs/django-test/lib/python3.5/site-packages/django/utils/log.py", line 10, in <mole>
from django.views.debug import ExceptionReporter, get_exception_reporter_filter
File "/root/envs/django-test/lib/python3.5/site-packages/django/views/debug.py", line 10, in <mole>
from django.http import (HttpResponse, HttpResponseServerError,
File "/root/envs/django-test/lib/python3.5/site-packages/django/http/__init__.py", line 4, in <mole>
from django.http.response import (HttpResponse, StreamingHttpResponse,
File "/root/envs/django-test/lib/python3.5/site-packages/django/http/response.py", line 13, in <mole>
from django.core.serializers.json import DjangoJSONEncoder
File "/root/envs/django-test/lib/python3.5/site-packages/django/core/serializers/__init__.py", line 23, in <mole>
from django.core.serializers.base import SerializerDoesNotExist
File "/root/envs/django-test/lib/python3.5/site-packages/django/core/serializers/base.py", line 6, in <mole>
from django.db import models
File "/root/envs/django-test/lib/python3.5/site-packages/django/db/models/__init__.py", line 6, in <mole>
from django.db.models.query import Q, QuerySet, Prefetch # NOQA
File "/root/envs/django-test/lib/python3.5/site-packages/django/db/models/query.py", line 13, in <mole>
from django.db.models.fields import AutoField, Empty
File "/root/envs/django-test/lib/python3.5/site-packages/django/db/models/fields/__init__.py", line 18, in <mole>
from django import forms
File "/root/envs/django-test/lib/python3.5/site-packages/django/forms/__init__.py", line 6, in <mole>
from django.forms.fields import * # NOQA
File "/root/envs/django-test/lib/python3.5/site-packages/django/forms/fields.py", line 18, in <mole>
from django.forms.utils import from_current_timezone, to_current_timezone
File "/root/envs/django-test/lib/python3.5/site-packages/django/forms/utils.py", line 15, in <mole>
from django.utils.html import format_html, format_html_join, escape
File "/root/envs/django-test/lib/python3.5/site-packages/django/utils/html.py", line 16, in <mole>
from .html_parser import HTMLParser, HTMLParseError
File "/root/envs/django-test/lib/python3.5/site-packages/django/utils/html_parser.py", line 12, in <mole>
HTMLParseError = _html_parser.HTMLParseError
AttributeError: mole 'html.parser' has no attribute 'HTMLParseError'
(django-test) root@localhost:~/source/djangotest# django-admin startproject superlists
Traceback (most recent call last):
File "/root/envs/django-test/bin/django-admin", line 11, in <mole>
sys.exit(execute_from_command_line())
File "/root/envs/django-test/lib/python3.5/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/root/envs/django-test/lib/python3.5/site-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/root/envs/django-test/lib/python3.5/site-packages/django/__init__.py", line 18, in setup
from django.utils.log import configure_logging
File "/root/envs/django-test/lib/python3.5/site-packages/django/utils/log.py", line 10, in <mole>
from django.views.debug import ExceptionReporter, get_exception_reporter_filter
File "/root/envs/django-test/lib/python3.5/site-packages/django/views/debug.py", line 10, in <mole>
from django.http import (HttpResponse, HttpResponseServerError,
File "/root/envs/django-test/lib/python3.5/site-packages/django/http/__init__.py", line 4, in <mole>
from django.http.response import (HttpResponse, StreamingHttpResponse,
File "/root/envs/django-test/lib/python3.5/site-packages/django/http/response.py", line 13, in <mole>
from django.core.serializers.json import DjangoJSONEncoder
File "/root/envs/django-test/lib/python3.5/site-packages/django/core/serializers/__init__.py", line 23, in <mole>
from django.core.serializers.base import SerializerDoesNotExist
File "/root/envs/django-test/lib/python3.5/site-packages/django/core/serializers/base.py", line 6, in <mole>
from django.db import models
File "/root/envs/django-test/lib/python3.5/site-packages/django/db/models/__init__.py", line 6, in <mole>
from django.db.models.query import Q, QuerySet, Prefetch # NOQA
File "/root/envs/django-test/lib/python3.5/site-packages/django/db/models/query.py", line 13, in <mole>
from django.db.models.fields import AutoField, Empty
File "/root/envs/django-test/lib/python3.5/site-packages/django/db/models/fields/__init__.py", line 18, in <mole>
from django import forms
File "/root/envs/django-test/lib/python3.5/site-packages/django/forms/__init__.py", line 6, in <mole>
from django.forms.fields import * # NOQA
File "/root/envs/django-test/lib/python3.5/site-packages/django/forms/fields.py", line 18, in <mole>
from django.forms.utils import from_current_timezone, to_current_timezone
File "/root/envs/django-test/lib/python3.5/site-packages/django/forms/utils.py", line 15, in <mole>
from django.utils.html import format_html, format_html_join, escape
File "/root/envs/django-test/lib/python3.5/site-packages/django/utils/html.py", line 16, in <mole>
from .html_parser import HTMLParser, HTMLParseError
File "/root/envs/django-test/lib/python3.5/site-packages/django/utils/html_parser.py", line 12, in <mole>
HTMLParseError = _html_parser.HTMLParseError
AttributeError: mole 'html.parser' has no attribute 'HTMLParseError'5767757677
原因
HTMLParseError在pythons3.5已經沒有了
解決方法
將python版本回退到3.3或3.4
升級django版本
㈣ python3 mongodb創建資料庫在哪個文件
Python是跨平台的,可以運行在Windows、Mac和各種linux/Unix系統上。在Windows上寫Python程序,放到Linux上也是能夠運行的。
㈤ python 怎麼創建create mysql的資料庫
有個庫叫做mysql-python
也可以使用odbc方式用pyodbc
mysql好像還不支持點陣圖索引
㈥ python3中,如何把字典中的key和value循環存入MySql資料庫
有些資料庫可以直接存鍵值對,比如redis.
mysql的話可以考慮列表用特殊字元分隔,保存最後的字元串。但損失性能和不符合資料庫範式。
㈦ 如何用python創建資料庫
通過以下的內容你就可以輕松的運用Python資料庫連接池的相關步驟,希望下面的文章會對你有所收獲。 請求連接: 1. db=pool.connection()2. 你可以使用這些連接有如原始的DB-API 2一樣。而實際使用的是``SteadyDB``版本的強硬連接。請注意連接可以與其他線程共享,只要你設置 maxshared 參數為非零,並且DB-API 2模塊也允許。如果你想要使用專用連接則使用: 1. db=pool.connection(0)2. 如果你不再需要這個連接了,則可以返回給連接池使用 db.close()。你也可以使用相同的方法獲取另一個連接。警告:在一個多線程環境,不要使用下面的方法: 1. pool.connection().cursor().execute(...)2. 3. db=pool.connection()4. 5. cur=db.cursor()6. 7. cur.execute(...)8. 9. res=cur.fetchone()10. 11. cur.close() # or del cur12. 13. db.close() # or del db14. 示例 [方便你將來直接使用] 使用PersistentDB 模塊 1. import threading,time,datetime2. 3. import MySQLdb4. 5. import DBUtils.PersistentDB6. 7. persist=DBUtils.PersistentDB.PersistentDB(MySQLdb,100,host='localhost',user='root',passwd='321',db='test',charset='utf8')8. 9. conn=persist.connection()10. 11. cursor=conn.cursor()12. 13. cursor.execute("insert into me values(1,'22222')")14. 15. conn.commit()16. 17. conn.close()18. 通過以上的內容你就可以得到資料庫連接了! 作者:不詳 來源:網路
㈧ python3往Mysql資料庫插入數據
if __name__ == __main__下邊的代碼發來看看
報錯信息說少了個參數author
㈨ python3 怎麼連接資料庫
Python是計算機常用的計算機語言,在實際的操作中我們會涉及到Python連接資料庫的相關實際操作,假如你對Python連接資料庫的實際操作方案感興趣或是有疑問,你都可以瀏覽下面的文章。一. Python和mysql資料庫連接Python 要連接 MySQL 可以使用 MySQL_python模塊首先確定是否安裝,在指令模式輸入 python,然後便可以開始檢查:Python 2.5.1 (r251:54863, May 2 2007, 16:56:35)[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 Type "help", "right", "credits" or "license"
for more information. >>> import MySQLdb Traceback (most recent call last): File "", line 1, in ImportError: No mole named MySQLdb >>> exit() 如果見以上面的"ImportError: No mole named MySQLdb" 一句,便表示系統沒有安裝,注意:在shell中,輸出是 區分大小寫的也可以通過輸入下面這些命令來測試你的資料庫配置:>>> from django.db import connection >>>
cursor = connection.cursor() 如果沒有顯示什麼錯誤信息,那麼你的資料庫配置是正確的。 否則,你就得查看錯誤信息來糾正錯誤。上面的相關代碼是對Python連接資料庫中Python和mysql資料庫連接的前部分代碼的示例。 安裝mysql_python模塊到MySQLdb 官方網站 下載並安裝MySQLdb版本:(win)MySQL-python-1.2.2.win32-py2.6.exe 直接運行安裝即可按如下步驟安裝$ tar zxvf MySQL-python-1.2.2.tar.gz $ cd MySQL-python-1.2.2 $ python setup.py build $ python setup.py install 附件: libguide40.dll.zip(77.3 KB) libmmd.dll.zip(169 KB) libmySQL.dll.zip(861 KB) 以上就是對python連接資料庫中 python和mysql資料庫連接相關的內容的介紹,望採納