Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!news.roellig-ltd.de!open-news-network.org!news.muarf.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'parameters': 0.04; 'mrab': 0.05; 'subject:Python': 0.06; '__name__': 0.09; 'cursor': 0.09; 'null,': 0.09; 'valueerror:': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; "'__main__':": 0.16; "'a',": 0.16; '23,': 0.16; 'guys,': 0.16; 'message):': 0.16; 'topics': 0.16; 'wrote:': 0.18; 'meant': 0.20; 'import': 0.22; 'cc:addr:python.org': 0.22; 'exists': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'second': 0.26; 'post': 0.26; 'primary': 0.26; 'values': 0.27; 'header:In-Reply- To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; 'author,': 0.31; 'file': 0.32; 'url:python': 0.33; '(most': 0.33; 'table': 0.34; 'skip:d 20': 0.34; 'created': 0.35; 'but': 0.35; 'received:google.com': 0.35; '14,': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'christian': 0.38; 'skip:& 10': 0.38; 'skip:- 10': 0.38; 'pm,': 0.38; 'recent': 0.39; 'skip:& 20': 0.39; 'called': 0.40; 'url:mail': 0.40; 'skip:\xc2 10': 0.60; 'new': 0.61; '30,': 0.65; '20,': 0.68; 'subject:there': 0.68; 'certain,': 0.84; 'id,': 0.84; 'message)': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:cc :content-type; bh=PxVwG08W28i1mpaQqtjTSCG+9yJiJPN/R5kiJJFDyxE=; b=Yk31dgh3XdvxscqFHe1zu0++so76xxosGyLmJuwAdBbBOQMoDmlCbn8sw9gDJH2Y36 dHKaJUoo1I1CINCE/iq5t32jXOash5lo6dibnuwYqs3nhkev+IXou288z1Au1gGPQymC zoqHHMcGQPko2YrDrNoyvJsKI3i00tumid30GFWKgl5hfOF1LxmRhoKNOcsR+tlaHMQE RQT+lzEUV7OdBxDH+jarkDwrC0JbNl5LeXCop3sQJvJ4blMiQ2Ev5NOA5YYy/c9Lbl6m Sgrxavyi0pCUOxc8WpGU/XEXtJkLvRhz4DH2aFotiNIs3RYZ0NAq4HAyu3kEWaei3Inu T+DA== X-Received: by 10.112.166.1 with SMTP id zc1mr6053516lbb.90.1413844255867; Mon, 20 Oct 2014 15:30:55 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <544565E8.6050702@mrabarnett.plus.com> References: <9a0c67be-de3a-4770-bf06-e158783bfff0@googlegroups.com> <54424691$0$12978$c3e8da3$5496439d@news.astraweb.com> <544565E8.6050702@mrabarnett.plus.com> From: Juan Christian Date: Mon, 20 Oct 2014 20:30:35 -0200 Subject: Re: Is there an easy way to control indents in Python Cc: Python Content-Type: multipart/alternative; boundary=001a11c32bd6a386860505e244e5 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 172 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1413844258 news.xs4all.nl 2844 [2001:888:2000:d::a6]:53583 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79345 --001a11c32bd6a386860505e244e5 Content-Type: text/plain; charset=UTF-8 Sorry guys, my post about SQL was not meant to be here!!! On Mon, Oct 20, 2014 at 5:43 PM, MRAB wrote: > On 2014-10-20 20:04, Juan Christian wrote: > >> Ok, new code using ?: >> >> import sqlite3 >> >> db = sqlite3.connect('db.sqlite') >> >> >> def create_db(): >> db.execute(''' >> CREATE TABLE TOPICS( >> ID INT PRIMARY KEY NOT NULL, >> URL VARCHAR NOT NULL, >> AUTHOR VARCHAR NOT NULL, >> MESSAGE VARCHAR NOT NULL >> ); >> ''') >> >> >> def insert_db(_id, url, author, message): >> db.execute("INSERT INTO TOPICS (ID, URL, AUTHOR, MESSAGE) VALUES >> (?, ?, ?, ?)", (_id, url, author, message)) >> db.commit() >> >> >> def get_db(_id): >> cursor = db.execute("SELECT ID, URL, AUTHOR, MESSAGE FROM TOPICS WHERE >> ID = ?", (_id)) >> return cursor.fetchone() >> >> >> if __name__ == '__main__': >> create_db() >> insert_db(12, 'abc.com ', 'a', 'b') >> print(get_db(12)) >> db.close() >> >> ------------- >> >> But now when I execute I get >> >> Traceback (most recent call last): >> File ".\sql.py", line 30, in >> print(get_db(12)) >> File ".\sql.py", line 23, in get_db >> cursor = db.execute("SELECT ID, URL, AUTHOR, MESSAGE FROM TOPICS >> WHERE ID = ?", (_id)) >> ValueError: parameters are of unsupported type >> >> ------------- >> >> I'm not certain, but I think that the SQL type is called "INTEGER", not > "INT". > > And the second time, again, I get >> >> Traceback (most recent call last): >> File ".\sql.py", line 28, in >> create_db() >> File ".\sql.py", line 14, in create_db >> ''') >> sqlite3.OperationalError: table TOPICS already exists >> >> That's because you created the table the last time you ran it. > > -- > https://mail.python.org/mailman/listinfo/python-list > --001a11c32bd6a386860505e244e5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Sorry guys, my post about SQL was not meant to be here!!!<= /div>

On Mon, Oct = 20, 2014 at 5:43 PM, MRAB <python@mrabarnett.plus.com> wrote:
On 2014-10-20= 20:04, Juan Christian wrote:
Ok, new code using ?:

import sqlite3

db =3D sqlite3.connect('db.sqlite')


def create_db():
=C2=A0 =C2=A0 =C2=A0db.execute('''
CREATE TABLE TOPICS(
ID INT PRIMARY KEY NOT NULL,
URL VARCHAR NOT NULL,
AUTHOR VARCHAR NOT NULL,
MESSAGE VARCHAR NOT NULL
);
''')


def insert_db(_id, url, author, message):
=C2=A0 =C2=A0 =C2=A0db.execute("INSERT INTO TOPICS (ID, URL, AUTHOR, M= ESSAGE) VALUES
(?, ?, ?, ?)", (_id, url, author, message))
=C2=A0 =C2=A0 =C2=A0db.commit()


def get_db(_id):
cursor =3D db.execute("SELECT ID, URL, AUTHOR, MESSAGE FROM TOPICS WHE= RE
ID =3D ?", (_id))
return cursor.fetchone()


if __name__ =3D=3D '__main__':
create_db()
insert_db(12, 'abc.com= <http://abc.com>= 9;, 'a', 'b')
print(get_db(12))
db.close()

-------------

But now when I execute I get

Traceback (most recent call last):
=C2=A0 =C2=A0File ".\sql.py", line 30, in <module>
=C2=A0 =C2=A0 =C2=A0print(get_db(12))
=C2=A0 =C2=A0File ".\sql.py", line 23, in get_db=
=C2=A0 =C2=A0 =C2=A0cursor =3D db.execute("SELECT ID, URL, AUTHOR, MES= SAGE FROM TOPICS
WHERE ID =3D ?", (_id))
ValueError: parameters are of unsupported type

-------------

I'm not certain, but I think that the SQL type is called "INTEGER&= quot;, not
"INT".

And the second time, again, I get

Traceback (most recent call last):
=C2=A0 =C2=A0File ".\sql.py", line 28, in <module>
=C2=A0 =C2=A0 =C2=A0create_db()
=C2=A0 =C2=A0File ".\sql.py", line 14, in create_db
=C2=A0 =C2=A0 =C2=A0''')
sqlite3.OperationalError: table TOPICS already exists

That's because you created the table the last time you ran it.

--
https://mail.python.org/mailman/listinfo/python-list

--001a11c32bd6a386860505e244e5--