django mysql 연동시 에러 질문드립니다.

sysmoon의 이미지

GET 메소드를 받으면 장고가 디비 연동해서 데이터를 뿌려주는 형식입니다.

HTTP GET이 하나씩 올때는 문제가 안되는데.
동시에 여러개의 HTTP Get이 오게 되면 -> Commands out of sync; you can't run this command now
에러가 발생합니다.

mysql connection은 하나만 글로벌하게 만들어서 쓰고 있는데,
하나의 컨넥션에 동시에 여러 query 문을 전송하는게 문제가 발생할 수 있나요?
자바에서는 하나의 컨넥션 객체를 이용해서 동시에 쿼리 잘 했던 것 같은데.. 암튼 도와주십쇼!^^

아래는 제가 쓰는 DB class 입니다.

code snippet

dbConn = MySQLdb.Connect(db='log_for_wave', user='sysmoon', passwd='1234qwer', host='localhost', charset='utf8', use_unicode=True)
 
class DB:
	global dbConn
 
	def __init__(self):
		self.dbConn = dbConn;
 
	def connect(self):
	    self.dbConn = MySQLdb.Connect(db='log_for_wave', user='sysmoon', passwd='1234qwer', host='localhost', charset='utf8', use_unicode=True)
 
	def query(self, sql):
		try:
		    cursor = self.dbConn.cursor(MySQLdb.cursors.DictCursor)
		    cursor.execute(sql)
		except (AttributeError, MySQLdb.OperationalError):
		    self.connect()
		    cursor = self.dbConn.cursor(MySQLdb.cursors.DictCursor)
		    cursor.execute(sql)
		return cursor
onhachoe의 이미지

db컨넥션은 하나의 연결을 의미합니다.
순차적으로 퀴리를 받는거죠 (implemenation에 따라 쿼리를 큐에 집어넣고 순차적으로 실행한다면 가능은 하겠죠 ^^)
게다가 transaction을 하게 된다면 하나의 컨넥션으로 일을 처리한다는 것은 말이 되지 않습니다.
commit이 되기 전에 shallow logging만 될뿐 실제로 디비에 쓰인다고 보긴 힘드니까요.

connection pool 어렵지 않게 구현할 수 있습니다.
그리고 이미 장고에서 mysql driver를 지원하는것으로 아는데 왜 다시 구현하려고 하십니까?

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.