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.openConnection.openConnection()
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 1505
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.openConnection.openConnection()
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.openConnection.openConnection()
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.scanDirsAndFiles(dirPath)
File "/home/pofuk/MzMFIleShare/sharePanel.py", line 158, in
scanDirsAndFiles
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 scanDirsAndFiles(self, dirPath):
for item in os.listdir(dirPath):
if os.path.isdir(os.path.join(dirPath, item)):
scanDirsAndFiles(os.path.join(dirPath, item))
if os.path.isfile(os.path.join(dirPath, item)):
user_name = login.getUserName()
fileName = item
fileSize = os.path.getsize(os.path.join(dirPath, item))
filePathLocal = os.path.join(dirPath, 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.openConnection.openConnection()
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("files", 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.scanDirsAndFiles(dirPath) File "/home/pofuk/MzMFIleShare/sharePanel.py", line 158, in scanDirsAndFiles 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 scanDirsAndFiles(self, dirPath): for item in os.listdir(dirPath): if os.path.isdir(os.path.join(dirPath, item)): scanDirsAndFiles(os.path.join(dirPath, item)) if os.path.isfile(os.path.join(dirPath, item)): user_name = login.getUserName() fileName = item fileSize = os.path.getsize(os.path.join(dirPath, item)) filePathLocal = os.path.join(dirPath, 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.openConnection.openConnection() 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("files", 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_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,
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_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,
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:...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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,...
| |