㈠ 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数据库连接相关的内容的介绍,望采纳