Hy! I have error something like this
TypeError: unbound method insert() must be called with insertData
instance as first argument (got str instance instead)
CODE:
File1.py
sql.insertData. insert("files", data)
sql.py
class insertData:
def insert(self, dataTable, data):
conn = self.openConnec tion.openConnec tion()
cursor = conn.cursor()
sql ="INSERT INTO "+dataTable +" (user_name, file_name, file_size,
file_path_local , file_path_FTP, curent_location , FTP_valid_time,
uploaded, last_modified, last_verified, file_type, file_category) VLAUES
"+data
cursor.execute( sql)
conn.Close()
Help and advice neaded! 9 1513
On Dec 21, 9:11 am, SMALLp <po...@email. t-com.hrwrote:
Hy! I have error something like this
TypeError: unbound method insert() must be called with insertData
instance as first argument (got str instance instead)
CODE:
File1.py
sql.insertData. insert("files", data)
sql.py
class insertData:
def insert(self, dataTable, data):
conn = self.openConnec tion.openConnec tion()
cursor = conn.cursor()
sql ="INSERT INTO "+dataTable +" (user_name, file_name, file_size,
file_path_local , file_path_FTP, curent_location , FTP_valid_time,
uploaded, last_modified, last_verified, file_type, file_category) VLAUES
"+data
cursor.execute( sql)
conn.Close()
Help and advice neaded!
I think you need to post the real traceback or the real code since
your error message doesn't look like it has anything to do with the
code above. At least, I do not see a method named "insert".
Which database module are you using?
Mike
On Dec 21, 2007 9:11 AM, SMALLp <po***@email. t-com.hrwrote:
Hy! I have error something like this
TypeError: unbound method insert() must be called with insertData
instance as first argument (got str instance instead)
CODE:
File1.py
sql.insertData. insert("files", data)
sql.py
class insertData:
def insert(self, dataTable, data):
conn = self.openConnec tion.openConnec tion()
cursor = conn.cursor()
sql ="INSERT INTO "+dataTable +" (user_name, file_name, file_size,
file_path_local , file_path_FTP, curent_location , FTP_valid_time,
uploaded, last_modified, last_verified, file_type, file_category) VLAUES
"+data
cursor.execute( sql)
conn.Close()
Help and advice neaded!
--
You are unclear on the distinction between classes and instances of
those classes. Following Python convention and naming your classes in
CapsCase (InsertData not insertData) would help. I recommend taking 2
giant steps backward and working through the python tutorial and dive
into python, then coming back to this project.
Traceback (most recent call last):
File "/home/pofuk/MzMFIleShare/sharePanel.py", line 130, in share
self.scanDirsAn dFiles(dirPath)
File "/home/pofuk/MzMFIleShare/sharePanel.py", line 158, in
scanDirsAndFile s
sql.insertData. insert("files", data)
TypeError: unbound method insert() must be called with insertData
instance as first argument (got str instance instead)
share.py
<snip>
def scanDirsAndFile s(self, dirPath):
for item in os.listdir(dirP ath):
if os.path.isdir(o s.path.join(dir Path, item)):
scanDirsAndFile s(os.path.join( dirPath, item))
if os.path.isfile( os.path.join(di rPath, item)):
user_name = login.getUserNa me()
fileName = item
fileSize = os.path.getsize (os.path.join(d irPath, item))
filePathLocal = os.path.join(di rPath, item)
filePathFTP = ""
currentLocation = "Local"
FTP_valid_time = 7
uploaded = ""
lastModified = "NOW()"
lastVerified = "NOW()"
fileType = "file"
fileCategory = "Ostalo"
data = [fileName, fileSize, filePathLocal, filePathFTP,
currentLocation , FTP_valid_time, uploaded, lastModified, lastVerified,
fileType, fileCategory]
sql.insertData. insert("files", data)
<snip>
class insertData:
def insert(self, dataTable, data):
conn = self.openConnec tion.openConnec tion()
cursor = conn.cursor()
sql ="INSERT INTO "+dataTable +" (user_name, file_name, file_size,
file_path_local , file_path_FTP, curent_location , FTP_valid_time,
uploaded, last_modified, last_verified, file_type, file_category) VLAUES
"+data
cursor.execute( sql)
conn.Close()
It doesn't look like you are instantiating the insertData class. You
would need to do something like:
# untested
foo = insertData()
foo.insert("fil es", data)
But I agree with Chris. You really do need to go through a tutorial on
using classes and following Python naming conventions. Dive Into
Python and some of the other online resources are very helpful.
This is something that I have trouble with myself since wxPython uses
CamelCase for classes and methods/functions and and most
recommendations for plain Python seem to only want CamelCase for
classes and something like myFunct or myMethod for the other objects.
Mike ky******@gmail. com wrote:
>Traceback (most recent call last): File "/home/pofuk/MzMFIleShare/sharePanel.py", line 130, in share self.scanDirsAn dFiles(dirPath) File "/home/pofuk/MzMFIleShare/sharePanel.py", line 158, in scanDirsAndFil es sql.insertData. insert("files", data) TypeError: unbound method insert() must be called with insertData instance as first argument (got str instance instead)
share.py
<snip>
> def scanDirsAndFile s(self, dirPath): for item in os.listdir(dirP ath): if os.path.isdir(o s.path.join(dir Path, item)): scanDirsAndFile s(os.path.join( dirPath, item)) if os.path.isfile( os.path.join(di rPath, item)): user_name = login.getUserNa me() fileName = item fileSize = os.path.getsize (os.path.join(d irPath, item)) filePathLocal = os.path.join(di rPath, item) filePathFTP = "" currentLocation = "Local" FTP_valid_time = 7 uploaded = "" lastModified = "NOW()" lastVerified = "NOW()" fileType = "file" fileCategory = "Ostalo"
data = [fileName, fileSize, filePathLocal, filePathFTP, currentLocatio n, FTP_valid_time, uploaded, lastModified, lastVerified, fileType, fileCategory]
sql.insertData. insert("files", data)
<snip>
>class insertData: def insert(self, dataTable, data): conn = self.openConnec tion.openConnec tion() cursor = conn.cursor() sql ="INSERT INTO "+dataTable +" (user_name, file_name, file_size, file_path_loca l, file_path_FTP, curent_location , FTP_valid_time, uploaded, last_modified, last_verified, file_type, file_category) VLAUES "+data cursor.execute( sql) conn.Close()
It doesn't look like you are instantiating the insertData class. You
would need to do something like:
# untested
foo = insertData()
foo.insert("fil es", data)
But I agree with Chris. You really do need to go through a tutorial on
using classes and following Python naming conventions. Dive Into
Python and some of the other online resources are very helpful.
This is something that I have trouble with myself since wxPython uses
CamelCase for classes and methods/functions and and most
recommendations for plain Python seem to only want CamelCase for
classes and something like myFunct or myMethod for the other objects.
Mike
Thanks! I solved the problem. And I thing i understand now.
On Fri, 2007-12-21 at 18:06 +0100, SMALLp wrote:
sql ="INSERT INTO "+dataTable +" (user_name, file_name, file_size,
file_path_local , file_path_FTP, curent_location , FTP_valid_time,
uploaded, last_modified, last_verified, file_type, file_category) VLAUES
"+data
cursor.execute( sql)
Thanks! I solved the problem. And I thing i understand now.
You may have solved your initial problem, but the above snippet raises
two red flags:
1) Why is the table name coming from a variable? This implies to me that
you a working with a collection of tables with different names that all
have the same column names. If that is the case, that smells of really
bad database design. If at all possible, those tables should be merged
into one table that has an additional column (or set of columns) for
distinguishing which "fragment" each row is in.
2) Sticking literal values into an SQL query string is a bad idea. You
should learn about parametrized queries, e.g. here: http://informixdb.blogspot.com/2007/...in-blanks.html
Hope this helps,
--
Carsten Haese http://informixdb.sourceforge.net
Carsten Haese wrote:
On Fri, 2007-12-21 at 18:06 +0100, SMALLp wrote:
>>> sql ="INSERT INTO "+dataTable +" (user_name, file_name, file_size, file_path_lo cal, file_path_FTP, curent_location , FTP_valid_time, uploaded, last_modified, last_verified, file_type, file_category) VLAUES "+data cursor.execute( sql)
>Thanks! I solved the problem. And I thing i understand now.
You may have solved your initial problem, but the above snippet raises
two red flags:
1) Why is the table name coming from a variable? This implies to me that
you a working with a collection of tables with different names that all
have the same column names. If that is the case, that smells of really
bad database design. If at all possible, those tables should be merged
into one table that has an additional column (or set of columns) for
distinguishing which "fragment" each row is in.
2) Sticking literal values into an SQL query string is a bad idea. You
should learn about parametrized queries, e.g. here: http://informixdb.blogspot.com/2007/...in-blanks.html
Hope this helps,
Good question. I'm using only one tale and have no idea why i had table
name from variable. But every new knowledge comes handy.
One more question. How does my code looks like. I couldn't find any open
source program written in python to learn from, so i read some tutorials
and I'm not sure about how it looks.
On Dec 21, 1:44 pm, SMALLp <po...@email. t-com.hrwrote:
Carsten Haese wrote:
On Fri, 2007-12-21 at 18:06 +0100, SMALLp wrote:
>> sql ="INSERT INTO "+dataTable +" (user_name, file_name, file_size, file_path_loc al, file_path_FTP, curent_location , FTP_valid_time, uploaded, last_modified, last_verified, file_type, file_category) VLAUES "+data cursor.execute( sql)
Thanks! I solved the problem. And I thing i understand now.
You may have solved your initial problem, but the above snippet raises
two red flags:
1) Why is the table name coming from a variable? This implies to me that
you a working with a collection of tables with different names that all
have the same column names. If that is the case, that smells of really
bad database design. If at all possible, those tables should be merged
into one table that has an additional column (or set of columns) for
distinguishing which "fragment" each row is in.
2) Sticking literal values into an SQL query string is a bad idea. You
should learn about parametrized queries, e.g. here: http://informixdb.blogspot.com/2007/...in-blanks.html
Hope this helps,
Good question. I'm using only one tale and have no idea why i had table
name from variable. But every new knowledge comes handy.
One more question. How does my code looks like. I couldn't find any open
source program written in python to learn from, so i read some tutorials
and I'm not sure about how it looks.
You couldn't find any programs written in Python? What the!?
Here's a few: http://cheeseshop.python.org/pypi/UliPad/3.6/ http://spambayes.sourceforge.net/ http://sourceforge.net/softwaremap/t...p?form_cat=178
Mike ky******@gmail. com a écrit :
On Dec 21, 9:11 am, SMALLp <po...@email. t-com.hrwrote:
(snip)
>>class insertData: def insert(self, dataTable, data):
(snip)
>
I think you need to post the real traceback or the real code since
your error message doesn't look like it has anything to do with the
code above. At least, I do not see a method named "insert".
May I suggest a new pair of glasses ?-)
SMALLp a écrit :
(snip)
One more question. How does my code looks like. I couldn't find any open
source program written in python
You must be jocking ? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Svens |
last post by:
Hey everyone! I'm a math student working on a short script involving
logs. I have a function on my scientific calculator, and was wondering
if there was a similar funtion in python.
For example:
(log65536)/(log4)= 8
I've searched around a bit and haven't been able to find anything.
|
by: jvax |
last post by:
Hi all,
I hope I'm posting in the right NG...
I have a data text file I want to read from a c++ program.
the data file goes like this:
90 # number of balls
33
42
13
|
by: Mike Malter |
last post by:
I am just starting to work with reflection and I want to create a log that saves relevant information if a method call fails so I
can call that method again later using reflection.
I am experimenting a bit with what I need to do this and have the following code snippet. But first if I pass the assembly name and
type to Activator.CreateInstance() it always fails. However if I walk my assembly and get a type value, the call to...
|
by: z_learning_tester |
last post by:
But I can't seem to find the answer.
The question is how do you reverse the words in a string?
Or how do you reverse the numbers listed in a string?
The example is usually something like:
Turn this string "1,2,3,4,..."
Into "...4,3,2,1"
This one seems hard enough let alone trying to turn a string of
space-seperated words around(is that even possible? a trick question
|
by: Blaze |
last post by:
I am doing the first walk through on the Visual Studio .Net walkthrough book
to learn a little about programming. I am having issues with the first
tutorial not running correctly. It seems that the build fails with what the
book tells me to do.
Specifically, I am doing this:
public authors1 GetAuthors()
{
authors1 authors = new Authors1();
| |
by: optimistx |
last post by:
As a beginner in javascript I had a question. I was reading FAQ and posts
here.
I became very unhappy: Obviously this group is mainly for wise, pedantic,
unkind etc people, who already know everything about javascript, and want
to prove that to everyone in a very harsh way?
Therefore, I skip the question, and we can go directly to the following
posts:
|
by: Roman Zeilinger |
last post by:
Hi
I have a beginner question concerning fscanf.
First I had a text file which just contained some
hex numbers:
0C100012
0C100012
....
|
by: a |
last post by:
Dear all vb.net developer
I want to know the time I need to master vb.net?
I'm beginner
|
by: Ben Keshet |
last post by:
I have a probably simple beginner's question -
I have a script that I am currently able to print its output. instead,
i want to write it into a file - I tried different versions of write()
but might have gotten the syntax wrong. the variable I want to write is
a line from a file I am reading:
"...
f = open('receptor.mol2', 'r')
line = f.readline()
|
by: roanhn |
last post by:
Hello.
I've to to write a master's thesis. Currently I deal with php, mysql, ajax.
Fate decreed that I've to choose one of this subjects:
1.gdi+ library in .net technology
2.ado.net technology in VS 2008.
I didn't have contact with Visual Studio, .NET. I only know some basics of c++.
My question is what subject of your point of view will be easier for absolute beginner in .net domain. From writing which subject I gain more knowledge...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |